You could access elements in Console by enter command: Console.log(<element name>) in the console tab(after F12 is hit). Mostly applicable for Chrome Browser.
Wednesday, July 26, 2017
Scenario: Access calendar using Selenium Webdriver
Generally Calendar elements have common attribute values(no unique values to consider) even if there are more than one in a web page, So it makes these elements too complex to access and work on them.
So here we use siblings in the xpath. Means we go to the previou or next sibling of this item and create xpath for that item. Once we are able to access that element, write sibling to the xpath to access calendar element.
Testing website: https://www.goibibo.com
code:
<a href="/accounting.html">yyy</a>
<h4>zzz</h4>
<h4> could be accessed using below code:
"//div[@class='canvas- graph']//a[@href='/accounting.html'][i[@class='icon-usd']]/following-sibling::h4"
Wednesday, July 19, 2017
Tuesday, July 18, 2017
Headless Driver
https://www.guru99.com/selenium-with-htmlunit-driver-phantomjs.html
package htmldriver; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.htmlunit.HtmlUnitDriver; public class htmlUnitYest { public static void main(String[] args) { // Creating a new instance of the HTML unit driver WebDriver driver = new HtmlUnitDriver(); //could use any browser here //And it will not pop browser instead it will run in the background. so majorly HtmlUnitDriver is used for Load Testing. // Navigate to Google driver.get("http://www.google.com"); // Locate the searchbox using its name WebElement element = driver.findElement(By.name("q")); // Enter a search query element.sendKeys("Guru99"); // Submit the query. Webdriver searches for the form using the text input element automatically // No need to locate/find the submit button element.submit(); // This code will print the page title System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } }
Subscribe to:
Posts (Atom)