我检查了现有的答案,似乎没有关于此的已回答问题。
这里是:硒32位驱动程序,IE 11,Windows 10 64位。我需要找到具有唯一静态id = 0idMenuTitle
或1idMenuTitle
HTML代码
SPAN onmouseover =“ if(this.style.backgroundColor!= BgColorON)this.style.backgroundColor = BgColorOVER;” “ onmouseout =” if(this.style.backgroundColor!= BgColorON)this.style.backgroundColor = BgColorOFF;“ id = 1idMenuTitle class = clsMenuTitle style =“ MAX-WIDTH:none; MIN-WIDTH:auto; MIN-HEIGHT:auto; MAX-HEIGHT:none; Background-COLOR:#cccc” minmax_bound =“ true” width =“ 100% “> menu1
我正在使用以下内容:
driver.findElement(By.id("0idMenuTitle")).click();
并且有错误
org.openqa.selenium.NoSuchElementException: Unable to find element with css selector == #\31 idMenuTitle
我正在尝试使用部分ID查找
driver.findElement(By.cssSelector("[id*=MenuTitle]")).click();
但是得到
org.openqa.selenium.ElementNotInteractableException: Element is not displayed
我也尝试过Xpath,同样的错误。如果我使用FF或GC,没有问题,但是我必须使用IE11,别无选择。找到没有以数字开头的id的元素没有问题...
有什么想法吗?
我正在尝试通过以0开头的id查找元素,但是selenium显示有关css选择器(?)和id#\ 31(???)的错误
[获得Element is not displayed
的原因是因为在交互时页面上看不到项目。产生WebDriverWait
()并等待elementToBeClickable
()
您需要考虑以下几点: