[英]Unable to locate element in Selenium using ID. Able to get the element on one page. However unable to locate when I navigate on another page
我正在尝试使用其 ID 作为定位器来获取按钮元素。 我有多个页面,所有页面上都存在相同的按钮。使用下面提到的相同代码,我能够在其中 2 个页面上获取元素,但在其他页面上,它返回的异常为
“没有这样的元素:无法定位元素:{"method":"css selector","selector":"#btn-show-support-info"}(会话信息:chrome=80.0.3987.132)”
代码行:
_btnSupportInfo = new WebDriverWait(
_Driver,
TimeSpan.FromSeconds(Convert.ToInt32(Environment.GetEnvironmentVariable("waitTime"))))
.Until(ExpectedConditions.ElementToBeClickable(By.Id("btn-show-support-info"))
);
完整的 XPATH:
/html/body/app-root/main/project-shell/div/div/client-header/div/form/div[6]/support-info/button
我也尝试过使用 xpath,但没有运气。
任何帮助将不胜感激。 :)
检查它是否在所有页面的路径下。 如果按钮在框架内,则需要先切换到框架,然后再查找元素
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.