Selenium
Selenium
Selenium Webdriver:
+++++++++++++++++++++++++++++++++++++++++
TestNG
http://testng.org/doc/documentation-main.html
Priorities , Groups,
Dependencies
Dataproviider,
HTML reports
++++++++++++++++++++++++++++++++++++++++++++
Maven
Jenkins
Git
++++++++++++++++++++++++++++++++++++++++++++
POM
Page factory
Hybrid framework
Notes
Pros of automated testing:
Improves accuracy
Easily increase productivity because it provides fast & accurate testing result
Ensure Consistency
Without human element, it's difficult to get insight into visual aspects of your UI like colors,
font, sizes, contrast or button sizes.
Limitations of Selenium:
Selenium only supports web based application and does not support windows based
application.
Selenium users lacks official support for the problems they face since it is an open source.
Limitations of WebDriver:
WebDriver operates on the OS level. Also, remember that different browsers communicate
with the OS in different ways. If a new browser comes out, it may have a different process of
communicating with the OS as compared to other browsers.
2.WebDriver has no built-in command that automatically generates a Test Results File.
You would have to rely on your IDE's output window, or design the report yourself using the
capabilities of your programming language and store it as text, HTML, etc.
Framework:
Simply: think about a framework as a set of tools put together to help you to accomplish
your job better and faster.
What is WebDriver?
WebDriver is a web automation framework that allows you to execute your tests against
different browsers
WebDriver also enables you to use a programming language in creating your test scripts.
Following programming languages are supported by WebDriver
Test Cases that are newly designed and not executed manually at least once.
ID
ClassName
Name
TagName
LinkText
PartialLinkText
XPath
CSS Selector
TestNG Annotations:
@BeforeSuite
@BeforeTest
@BeforeClass
@BeforeMethod
@Test
@BeforeMethod
@BeforeClass
@BeforeTest
@DataProvider
@Factory
@Listeners
@Parameters
Advantages of TestNG:
Selenium Grid can be used to execute same or different test scripts on multiple
platforms and browsers concurrently so as to achieve distributed test execution.
The fastest implementation of WebDriver is the HTMLUnitDriver. It is because the
HTMLUnitDriver does not execute tests in the browser.
Assert: In simple words, if the assert condition is true then the program control will
execute the next test step but if the condition is false, the execution will stop and
further test step will not be executed.
Verify: In simple words, there won’t be any halt in the test execution even though
the verify condition is true or false.
FirefoxDriver is a Java class, and it implements the WebDriver interface.
Object Repository is used to store element locator values in a centralized location
instead of hard coding them within the scripts. We do create a property file
(.properties) to store all the element locators and these property files act as an
object repository in Selenium WebDriver.
Selenium Webdriver does not require scroll to perform actions as it manipulates
DOM. But in certain web pages, elements only become visible once the user have
scrolled to them. In such cases scrolling may be necessary.
Select iframe by id
driver.switchTo().frame(“ID of the frame“);
Locating iframe using tagName
driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));
Locating iframe using index
frame(index)
driver.switchTo().frame(0);
frame(Name of Frame)
driver.switchTo().frame(“name of the frame”);
frame(WebElement element)
Select Parent Window
driver.switchTo().defaultContent();
DROPDOWN
Maven:
In general, the Group Id should correspond to your organization name, and the Artifact
Id should correspond to the project’s name. The version is up to your discretion as is the
packing and other fields. If this is a stand-alone project that does not have parent dependencies,
you may leave the Parent Project section as is. Fill out the appropriate information, and
click Finish.