How to Click on a Text in Selenium Webdriver 2.x
1- For Clicking on text 'PAAcctActivityData', you can use the below code:
driver.findElement(By.xpath("//span[.='PAAcctActivityData']")).click();
2- For Clicking on text 'PAAcctAddrEmail', you can use the below code:
driver.findElement(By.xpath("//span[.='PAAcctAddrEmail']")).click();
NOTE:- The above xpaths will locate thespan elements
with exact innerHTML/text as 'PAAcctActivityData'
or 'PAAcctAddrEmail'
, respectively.
By.linkText("PAAcctAcctRels")
won't work because that link has more text (ie ' currently selected
'), and the problem with your xpath is that is starts with .//
The following should work (I have avoided using * for performance)
By.xpath("//div[@id='primaryNavLevel2Z6_G868H4S0K881F0AAEO37LG28N0']/div[1]/a")
Try using //[@id='primaryNavLevel2Z6_G868H4S0K881F0AAEO37LG28N0']/div[1]/a/spanas xpath. Remove the initial '.' and add '/span' at the end.