Adsense

selenium xpath selector expamles

WebElement k1 = Login.driver.findElement(By.xpath("//table[@id='dijit_Menu_2']/tbody/tr[*]/td[contains(.,'name 2')]"));

//*[contains(@id, 'ctl00_btnAircraftMapCell')]//*[contains(@title, 'Select Seat')]

iconHelp= "//*[contains(@class, 'globalToolbar')]//*[contains(@title, 'Help')]";

To find a following element 

//div[contains(@title, 'Enter your name:')]/following-sibling::div/div/input

To find a previous element
ComponentXpath=".//*[@id='tableCmpsId']//div[text()='ComponnetName']/preceding::td[1]/div//input";

Using xPath to reach parent of an element
//div[@id='Histable']//div[text()='weather']/parent::div

Selecting an element with xpath and Selenium
//td[contains(@class,'Label') and text()='Code']

The nearest <div> ancestor of the context node.
ancestor::div[1]


Not contains
$x("//div[not(contains(@style,'display:none')) and contains(string(), 'Note:'))]")

$x("//div[contains(@class,'dijitContentPane')]/div[contains(@class,'contentPane')]/div[not(contains(@style,'display:none')) and contains(string(), 'Note:')]")

normalize-space

$x("//div[normalize-space()='Note: Default values are shown in bold.']")

newest questions on wordpress