【发布时间】:2019-01-31 21:10:09
【问题描述】:
我正在尝试使用 selenium 查找并单击此按钮:
<button class="orangeButton nextStep js-submitForm js-pop" data-href="/user/welcome/subscribe">Take me to my Subscriptions</button>
但是,没有 id 并且类名太长,所以我想使用 xpath。但是,我不明白如何使用它..
当前代码:
driver.FindElement(By.XPath("//button[@class='orangeButton nextStep js-submitForm js-pop\'")).Click();
但这因为不是有效的 xpath 参数而失败
【问题讨论】:
-
尝试删除多余的反斜杠并用方括号关闭谓词:
"//button[@class='orangeButton nextStep js-submitForm js-pop']"
标签: c# selenium xpath css-selectors webdriver