本文介绍了指针操作缺少或无效的类型参数-Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
运行程序时出现以下错误消息.
I am getting below mentioned error message while run program.
我试图单击子菜单,将鼠标悬停在主菜单上后将显示该子菜单.
I am trying to click on sub menu which will display after mouse hover on main menu.
以下代码:
public class ActionKeywords {
WebDriver driver = new FirefoxDriver();
@Test
public void openBrowser(){
driver.get("https://www.levissima.it/");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
@Test
public void verify_Menus(){
WebElement mainMenu = driver.findElement(By.xpath("//ul[@id='menu-main']/li/a"));
WebElement subMenu = driver.findElement(By.xpath("//a[contains(text(),'Impegno Per La Natura')]"));
Actions action = new Actions (driver);
action.moveToElement(mainMenu).perform();
action.click(subMenu).perform();
}
}
请协助!
推荐答案
要使Selenium 3.4.0与Mozilla Firefox浏览器53.x配合使用,您需要从此处.将其保存在您的计算机中提供壁虎驱动程序的绝对路径.通过对您自己的代码进行一些简单的调整,该代码可以很好地执行.
With Selenium 3.4.0 to work with Mozilla Firefox browser 53.x you need to download the latest geckodriver from here. Save it in your machine & provide the absolute path of the geckodriver. This code executes fine with some simple tweak to your own code.
WebDriver driver;
@BeforeTest
public void setup()
{
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
driver = new FirefoxDriver(dc);
driver.manage().window().maximize();
}
@Test
public void openBrowser(){
driver.get("https://www.levissima.it/");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
@Test
public void verify_Menus(){
WebElement mainMenu = driver.findElement(By.xpath("//ul[@id='menu-main']/li/a"));
WebElement subMenu = driver.findElement(By.xpath("//a[contains(text(),'Impegno Per La Natura')]"));
Actions action = new Actions (driver);
action.moveToElement(mainMenu).perform();
action.click(subMenu).perform();
}
输出为:
PASSED: openBrowser
PASSED: verify_Menus
===============================================
Default test
Tests run: 2, Failures: 0, Skips: 0
===============================================
让我知道这是否回答了您的问题.
Let me know if this answers your question.
这篇关于指针操作缺少或无效的类型参数-Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!