Beruflich Dokumente
Kultur Dokumente
Abstract methods are methods without structures but with only name
of the method
Ex:normal method
6.css syntax://tagname[attribute*='value'] or
tagname#id or tagname.classname
xpath types
relative xpath-does not depends on parent nodes
absolute xpath-finding xpath by using parent to child node
Contains()
Is another method in xpath with is ysed when when values of
attributes changing dynamically it will find attributes by using
partial text
Syntax tagname[contains,(@attribute,’partialtextvalue')]
Syntax
Tagname[@contains(text(),’textvalue of attribute')]
Using or in xpath
Syntax
Tagname[@attribute=’value' or secattribute=’value']
Syntax
Tagname[text()=’textofelement’]
dropdowns
1.static dropdown-static dropdown is which the options are
preloaded
dropdowns are clicked by using select class in java by creating
object
java alerts
radiobuttens
this are also webelements that are clicked by using locaters
techniques but if we need to click on radio butten which have same
attribute first we find count of that radio buttens by using
driver.findelements.size() keyword which count the total number
then we take them into list nd with the help of for and if loop we
click on that button
WAITS IN WEBDRIVER
Thread.sleep Command
▪ The sleep code always has to wait for the seconds mentioned
within the bracket, even if the work page is
ready after 5 seconds. So this test can slow down.
▪ Ex: Thread.sleep(5000); // Wait 5 Seconds
▪ Implicit Wait:
▪ Implicit Wait means informing selenium web driver to wait for
specific amount of time.
▪ If the web element is not visible after waiting for that
specific point then throw “NoSuchElementException”.
▪ Ex:
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
Explicit Wait:
▪ In Explicit wait along with wait time we also provide the wait
condition for particular WebElement.
▪ It will wait till the condition or the maximum wait time
provided before throwing the Exception
“ElementNotVisibleException”.
▪ Wait for the WebDriver to check whether the element exists or to
operate on it, visible or enabled or disabled
or clickable.
▪ Ex:
// Create a Object wait of WebdriverWait class
WebDriverWait wait = new WebDriverWait(driver,30);
// Using ExpectedConditions wait until element visibility
wait.until(ExpectedConditions.visibilityOfElementLocatedBy.tagName
("input")));
elementToBeClickable:
– wait.until(ExpectedConditions.elementToBeClickable(element)); //
Wait until element to be clickable on
page
▪ elementToBeSelected:
– wait.until(ExpectedConditions.elementToBeSelected(element)); //
Wait until element to be selectable on page
invisibilityOf:
– wait.until(ExpectedConditions.invisibilityOf(element)); // Wait
and check element is invisibility
▪ presenceOfAllElementsLocatedBy:
–
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy((By)
element)); // Wait until present element
located by.
▪ textToBePresentInElement:
– wait.until(ExpectedConditions.textToBePresentInElement(element,
"Text")); //// Wait until text present on
particular an element
▪ textToBePresentInElementValue:
– // Wait until element value present for a particular element.
–
wait.until(ExpectedConditions.textToBePresentInElementValue(elemen
t, "Value"));
▪ visibilityOf:
– // check element visibility
– wait.until(ExpectedConditions.visibilityOf(element));
Mouse Actions
– Mouse Hover
▪ moveToElement(WebElement).build().perform();
– Right Click
▪ contextClick(WebElement).build().perform();
– Double Click
▪ doubleClick(WebElement).build().perform();
– Drag and Drop
▪ dragAndDrop(Source WebElement, Target
WebElement).build().perform()
▪ clickAndHold(Source WebElement).moveToElement(Target
WebElement).release().build().perform();
– Slider
▪ moveToElement(WebElement).dragAndDropBy(WebElement, 300,
0).build().perform();
– Resizing
▪ moveToElement(WebElement).dragAndDropBy(WebElement, 100,
100).build().perform();
handling frames--- if the page having the tag name called iframe
or frame set then we decide that it is in frame
DesiredCapabilities ch=DesiredCapabilities.chrome();
//ch.acceptInsecureCerts();
ch.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
ch.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
(takescreenshot(driver)).getscreenshotas.(outputtypr.file)
default the file is saved
in src to copy the file from src to our required location we use
"fileutils." Class
File src=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(src,new File("C:\\Users\\rahul\\screenshot.png"));
GRID
"Desiredcababilities" is class
which is used to tell the selenium which browser we need to use
and os
FRAMEWORK
<classes>
<class name=test.day3/>
<methods>
<exclude name="that method name"/>
<methods/>
<class/>
<classes/>
groups in testng
groups are exclusively useful when we need to work on smoke
testing
for every class we use unique key word to treat them as a groups
and in xml
<test>
<groups>
<run>
<include name="smoke/>"
</run>
</groups>
</test>
helper annotations
Today topic
syntax:
<suite>
<listeners>
<listener class-name="package name.class name"/>
<listeners/>
<test>
@Override
public void onFinish(ITestContext arg0) {
// TODO Auto-generated method stub
@Override
public void onStart(ITestContext arg0) {
// TODO Auto-generated method stub
@Override
public void onTestFailedButWithinSuccessPercentage(ITestResult
arg0) {
// TODO Auto-generated method stub
@Override
public void onTestFailure(ITestResult arg0) {
System.out.println("Screen shot
captured====="+arg0.toString());
@Override
public void onTestSkipped(ITestResult arg0) {
// TODO Auto-generated method stub
@Override
public void onTestStart(ITestResult arg0) {
// TODO Auto-generated method stub
System.out.println("TestCase started===="
+arg0.toString());
}
@Override
public void onTestSuccess(ITestResult arg0) {
// TODO Auto-generated method stub
data driven
parameterization
in selenium we should not hard code the data like
username,password etc those are written in one properties file and
we use that prop file featured test cases
there are some cases which we need to drive data from excel sheet
and it is known as data driven from excel sheet
MAVEN
my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
we can also control which xml file to run if there are multiple
testng xml files by creating them as each profile
jenkins
LOG4J api
PAGE
OBJECT PATTERN MODEL
Coming in the morning and checking the nightly build result (If
you have any nightly build scheduled)
Work on the failures of the script you found during the nightly
builds.
Then you should check your Automation Report , whether Failed Test
cases are really failed i.e Whether Application functionality has
failed or script itself failed.
You need to check any new requirement has come, if so, you need to
modify your script.
Adding additional automation framework features and Writing &
testing more automation test scripts
we have daily,weekly meetings regarding to status