Sunday, July 27, 2014

How get xpath or CSS for sibling elements

XPATH for Sibling

//div[@class='about-membership-card'][1]/span[contains(text(),'Plus | $100')][1]/following-sibling::a[1]

CSS
div[id='about-membership-wrapper']>div[class='about-membership-cards']:first-of-type>div[class='about-membership-card']:first-of-type>span+a:first-of-type

 Indexes in CSS
div[id='about-membership-
wrapper']>div[class='about-membership-cards']>div[class='about-membership-card']:nth-child(2)>span+a:nth-child(2)



Thursday, July 3, 2014

Selenium WebDriver Handling child Windows




//Getting the existing windows handle incase we need to get back to the window.
String winHandleBefore = driver.getWindowHandle();

//Perform the click operation that opens new window
//Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
driver.switchTo().defaultContent();
  

 Switch To frame :
 
driver.switchTo().frame("studioFrame");