am working on selenium webdriver using JAVA !
am trying to pass a string dynamically using the variable exp
String exp=",,,4'-TETRA; P-CHLORIDE";
d.findElement(By.xpath("a[contains(text(),\""+exp+"\")]//ancestor::table//parent::div")).sendKeys(Keys.ARROW_DOWN);
but its giving me an error :
Unable to locate element: {"method":"xpath","selector":
"a[contains(text(),\",,,4'-TETRA; P-CHLORIDE\")]//ancestor::table//parent::div"
}
Use '"+exp+"'
instead of \\""+exp+"\\"
:
d.findElement(By.xpath("a[contains(text(),'"+exp+"')]//ancestor::table//parent::div")).sendKeys(Keys.ARROW_DOWN);
Update
d.findElement(By.xpath('a[contains(text(),"'+exp+'")]//ancestor::table//parent::div')).sendKeys(Keys.ARROW_DOWN);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.