[英]C# Selenium can't find element with WebDriverWait, i can see and click on it manually
Element im trying to locate: 元素im试图查找:
WebDriverWait wait = new WebDriverWait(browser, TimeSpan.FromSeconds(60));
wait.Until(ExpectedConditions.ElementExists(By.XPath("//use[@xlink:href='#core_mail']")));
File.WriteAllText("html.txt", browser.PageSource);
that just times out.. and the page loads way before 60 seconds. 只是超时而已。页面在60秒之前加载完毕。
svg
has a default namespace . svg
具有默认名称空间 。 You have to account for it: 您必须考虑到它:
//svg:use[@xlink:href='#core_mail']
Or ignore it with local-name()
: 或者使用
local-name()
忽略它:
//*[local-name() = 'use' and @xlink:href='#core_mail']
Though, to be fair, you don't have to dive into the markup that deeply, your "email" button is much higher in the tree - see the very first parent element partially visible on the screenshot - that's your desired element you probably want to locate instead. 不过,公平地说,您不必深入研究标记,您的“电子邮件”按钮在树中要高得多-看到屏幕快照中部分可见的第一个父元素-这可能是您想要的元素代替定位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.