I hope everyone played this hurdles on Google doodle here .
Post your best scores here and guess why I've posted this here.
Happy weekend
Regards,
SantoshSarma
isElementPresent(WebDriver driver,By by)
{
driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
try
{
driver.findElement(by);
return true;
}
catch(Exception e)
{
return false;
}
finally
{
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
}
//input[@id='firstname] OR //input[@name=firstname]
In this case no need of xpath locator because we can use By.id, By.name,By.cssSelector. //label[text()='First Name:']/parent::td/following-sibling::td/div/input
or
//label[text()='First Name:']/../../td/div/input
In above example,| parent | This keyword helps you to back track to parent node from child node. |
| following-sibling | This keyword helps you to go following-sibling. |
| preceding-sibling | This keyword helps you to go preceding-sibling. |
| .. | This also helps you to go parent node from child node |
| Select Last Name using contains | //label[contains(text(),'Last')]/../../td/div/input |
| Select Last Name using starts-with | //label[starts-with(text(),'Last')]/../../td/div/input |
<td class=name> </td>
<td class=name> </td>driver.findElement(By.cssSelector("td.name")); In css selector we can denote class name with dot (.)
<input id=create>driver.findElement(By.cssSelector("#create")).sendKeys("test"); shortcut for denoting id is #
<td value=dynamicValue_13232><td>driver.findElement(By.cssSelector("[value*=dynamicValue]")) * is for checking contained value
<div value=testing name=dynamic_2307></div>driver.findElement(By.cssSelector("[value=testing][name*=dynamic]"));
<td id=newRecord> </td>
<a onclick=gotonext()>Setup </a>
<a onclick=gotonext()>very long link text </a>
<td name=WebDriver> </td>
<td class=name> </td>