【发布时间】:2020-04-21 12:01:22
【问题描述】:
在此页面上https://www.bestbuy.ca/en-ca/category/laptops-macbooks/20352(这是笔记本电脑结果页面,其中列出了许多笔记本电脑,我正在尝试获取这台特定的笔记本电脑)
WebElement -- 'HP 15.6" Laptop - Silver (Intel Core i3-1005G1/256GB SSD/8GB RAM/Windows 10)' 使用 xpath 及以下是我的 xpath:
//div[contains(text(),'HP 15.6" Laptop - Silver (Intel Core i3-1005G1/256GB SSD/8GB RAM/Windows 10)')]
此 xpath 正确识别元素,但是当我在 eclipse 中粘贴此 xpath 时,它会在 15.6(即 15.6\")之后添加反斜杠 \
xpath("div[contains(text(),'HP 15.6\" Laptop - Silver (Intel Core i3-1005G1/256GB SSD/8GB RAM/Windows 10)')]"))
这就是为什么我的代码会抛出 element not found 异常。谁能帮我解决这个问题。
【问题讨论】:
标签: java selenium selenium-webdriver xpath