Selenium reports
extent report --> http://extentreports.com/
Allure report --> http://allure.qatools.ru/
Page Object Model : https://www.toptal.com/selenium/test-automation-in-selenium-using-page-object-model-and-page-factory
Selenium Frameworks
https://www.softwaretestinghelp.com/test-automation-frameworks-selenium-tutorial-20/
https://www.edureka.co/blog/selenium-framework-data-keyword-hybrid-frameworks
https://www.guru99.com/creating-keyword-hybrid-frameworks-with-selenium.html
For Selenium jar (selenium-server-standalone-x.x.x.jar) file need to be downloaded from the http://www.seleniumhq.org/download/. In the page the following section
can be used Selenium Standalone Server. on 11/26 the version of the jar file is 3.7.1
To download third party drivers like IE, Chrome, Firefox , Edge look for the heading "Third Party Drivers, Bindings, and Plugins" in the page http://www.seleniumhq.org/download
To get the browser agent details using selenium
Selenium Frameworks
https://www.softwaretestinghelp.com/test-automation-frameworks-selenium-tutorial-20/
https://www.edureka.co/blog/selenium-framework-data-keyword-hybrid-frameworks
https://www.guru99.com/creating-keyword-hybrid-frameworks-with-selenium.html
For Selenium jar (selenium-server-standalone-x.x.x.jar) file need to be downloaded from the http://www.seleniumhq.org/download/. In the page the following section
can be used Selenium Standalone Server. on 11/26 the version of the jar file is 3.7.1
To download third party drivers like IE, Chrome, Firefox , Edge look for the heading "Third Party Drivers, Bindings, and Plugins" in the page http://www.seleniumhq.org/download
To get the browser agent details using selenium
System.out
.println(getDriver().executeScript("return navigator.userAgent", ""));
To set the property of a browser
System.setProperty("webdriver.chrome.driver","c:\\Users\\libs\\chromedriver.exe")
To invoke the respective browser
ChromeDriver driver = new ChromeDriver();
To maximize the browser window we it is opened then use the below
driver.manage().windows().maximize()
To clear the cache and cookies we use the below
driver.manage().deleteAllCookies()
To browser a website page use the below
driver.get("http://www.google.com")
Responsive testing of website
To check the behavior of the website in various devices like laptop, tablet , mobile and etc.
To set the screen size we have the following command
Dimension dim = new Dimension(400,600);
driver.manage().window().setSize(dim);
To close the browser using selenium
driver.quit(); //All the windows of the browser will be closed by quit
driver.close(); //Close the currently active window. When selenium opens three windows and current active window will be closed
To get the title of the page
driver.getTitle();
To get the currentURL
driver.getCurrentUrl()
Navigate methods
driver.navigate().to("http://www.google.com"); --> driver.get and navigate().to are same
driver.navigate().back(); --> back to the browsing history
driver.navigate().forward(); --> Forward to the browsing history
driver.navigate().refresh(); --> To reload the page
To Identify elements in selenium below are eight ways. They are called as Identifiers or Locators
Id
name
TagName
classname
LinkText
PartialLinkText
css
xPath
WebElement userElement= driver.findElement(By.name("uid"));
WebElement userElement= driver.findElement(By.id("uid"));
Xpath we have Relative and Absolute Xpath
Relative when we use the search will be slow
Relative Xptah
//html_tagname[@attribute=value]
//html_tagname[@attribute=value and @attribute=value]
//html_tagname[@attribute=value or @attribute=value]
We also have functions for xpath
a. text() --> this can be used for anchor, td, div, span , h1 to h7 , body, li
b. contains()
c. starts-with()
//html_tagname[text()=value]
//htm_tagname[contains(@attribute,value)] or //@htm_tagname[contains(text(),value)]
//html_tagname[starts-with (@attribute, value)] or //@html_tagname[starts-with (text(), value)]
does not contain
//div[contains(@class,'errorInfoPanelItem')]//div[contains(@class,'p-col-12 no-pad')]//span[not(contains(@class,'bold'))]
Axes in xpath
a. preceding-sibling
b. following-sibling
c. preceding
d. following
e. Ancestor
f. Child
//html_tagname[@attribute='value']//axis::html_tagname2[@attribute=value]
in axis we have preceding-sibling or following-sibling or following or preceding or Ancestors or Child
findElement will return the first matching element when it returns more than one. //need to verify
sendKeys() --> To write test in a textbox we use this method
click() --> To click on button
getText()
getAttribute()
clearText()
To select value in dropdown or combobox we need to use Select class from selenium
Select --> org.openqa.selenium.support.ui.Select
to select the vale we have three options
selectByValue()
selectByIndex()
selectByVisibleText()
deselectAll()
deselectByIndex()
deselectByValue()
deselectByVisibleText()
getOptions()
getAllSelectedOptions()
getFirstSelectedOption()
Wait
a. PageLoadTimeout
b. ImplicitWait
c. ExplicitWait
For Explicit wait we need to be knowing more on the class ExpectedConditions
Thread.sleep() vs impilictwait()
Thread.sleep will wait for the time we specified and then will continue the process.
implicitwait will do pooling and once found it will resume the process .
Exceptions
a. NoSuchElementException
b. TimeoutException
c. WebDriverException --> When we close the browser which is opened by selenium and if the code runs then it will throw this Exception
d. NoAlertPresentException
e. NoSuchCookieException
f. StaleElementException
Frames :
to navigate to a frame or alert we need to use the method switchTo()
driver.swithTo().frame();
For frame we have three options
a. Identify by index
b. Identify by frame name
c. Identify by Webelement
driver.switchTo.alert();
to switch back to main window then use the below
driver.switchTo().defaultContent();
windowHandle() vs windowHandles()
To take screenshot in Selenium we will be using following class
TakesScreenshot
Design Patterns
Object Repository --> Page Object Model --> Page Object Factory
Framework
Data Driven
Keyword Driven
Hybrid Driven
**********************************************************************
To stop and start Selenium Hub and Node we have two options
Need to start and stop the hub and node service on specific port
Option 1:
to stop selenium hub and node we need to add the following in all the bat files
"-servlet org.openqa.grid.web.servlet.LifecycleServlet"
to stop hub (if we start at specific port then it will be good )
http://localhost:4444/lifecycle-manager?action=shutdown
to stop node (we need to start the node at specific port )
http://192.168.143.38:33134/extra/LifecycleServlet?action=shutdown
Option 2 :
Need start the hub and node on specific port and while shutdown kill the process on the specific port
a. Identify the process id running on specific port
netstat -ano | findstr 4444
b. To kill process-id
taskkill /F /PID <<proceess-id>>
https://stackoverflow.com/questions/2514803/how-to-close-selenium-hub-grid-from-command-prompt
No comments:
Post a Comment