当我将鼠标悬停在网页中的特定框架时,我必须选择网页链接,按钮(指向下一页的链接)将可见。
WebElement mainElement = driver.findElement(By.xpath(<frame xpath >));
Actions builder = new Actions(driver);
builder.moveToElement(mainElement);
WebElement button1 = driver.findElement(By.xpath("//*[@id='currentSkills']/div[1]/div/a"));
builder.moveToElement(button1).click().perform();
我仍然无法选择特定链接 当我执行时,出现以下错误 org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与之交互(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:131 毫秒
但是当我在 AUT 期间将鼠标指针悬停到特定帧时(只是移动到特定帧而不单击任何内容),则测试正在成功执行。
我知道这可以由 JS 处理。但我想知道 selenium webdriver 中是否有任何解决方案
最佳答案
在适用于各种浏览器的某些驱动程序上,有时这样的自定义操作将不起作用,除非您在创建驱动程序时显式启用 native 事件:
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(true);
driver = new FirefoxDriver(profile);
或在为远程驱动程序创建 DesiredCapability 时设置它的其他方法
DesiredCapabilities desiredCapabilities = DesiredCapabilities.internetExplorer();
desiredCapabilities.setCapability("nativeEvents", true);
关于java - 无法选择隐藏链接 - selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17288242/