Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Selenium WebDriver中启用按钮do verify?_Java_Selenium_Selenium Webdriver - Fatal编程技术网

Java 如何在Selenium WebDriver中启用按钮do verify?

Java 如何在Selenium WebDriver中启用按钮do verify?,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我有一个按钮部分产品,但它禁用时,鼠标悬停在部分产品,然后按钮是启用。我不知道写脚本在SeleniumWebDriver找到按钮时是否启用了它 @Test(priority = 4) public void TestSelectedItem() { driver.findElement(By.xpath("/html/body/app-root/ng-component/div/product-list/div/div/div/div/div[2]/div/div[3]/div/div

我有一个按钮部分产品,但它禁用时,鼠标悬停在部分产品,然后按钮是启用。我不知道写脚本在SeleniumWebDriver找到按钮时是否启用了它

@Test(priority = 4)
public void TestSelectedItem() {

    driver.findElement(By.xpath("/html/body/app-root/ng-component/div/product-list/div/div/div/div/div[2]/div/div[3]/div/div[1]/a")).click();
    Select drpItem = new Select(driver.findElement(By.id("pa_colors")));
    drpItem.selectByIndex(2);
    driver.findElement(By.className("add_to_cart_button")).click();

}

请帮助我。

我将用Python为您提供在元素上执行悬停操作的代码:

hover_company = driver.find_element_by_xpath("your XPath")
driver.execute_script("arguments[0].scrollIntoView(true);", hover_company)
hover = ActionChains(driver).move_to_element(hover_company)
hover.perform()
前两行滚动到您的元素,最后两行——在元素上执行悬停操作。 完成此操作后,您可以单击按钮。试穿一下

Java代码:

hover_company = driver.findElement(By.xpath("your XPath"));
driver.executeScript("arguments[0].scrollIntoView(true);", hover_company);
Actions hover = new Actions(driver);
hover.moveToElement(hover_company).perform();

我将为您提供Python代码,这些代码在元素上执行悬停操作:

hover_company = driver.find_element_by_xpath("your XPath")
driver.execute_script("arguments[0].scrollIntoView(true);", hover_company)
hover = ActionChains(driver).move_to_element(hover_company)
hover.perform()
前两行滚动到您的元素,最后两行——在元素上执行悬停操作。 完成此操作后,您可以单击按钮。试穿一下

Java代码:

hover_company = driver.findElement(By.xpath("your XPath"));
driver.executeScript("arguments[0].scrollIntoView(true);", hover_company);
Actions hover = new Actions(driver);
hover.moveToElement(hover_company).perform();

您能否共享相关的
HTML
?你看到什么错误了吗?请使用错误堆栈跟踪更新问题。执行与手动操作相同的操作。搜索如何在seleniumplease中访问url:,在站点中,当鼠标悬停在项目上时,按钮显示。当按钮被禁用时,如何使用Selenium Webdriver find按钮?能否共享相关的
HTML
?你看到什么错误了吗?请使用错误堆栈跟踪更新问题。执行与手动操作相同的操作。搜索如何在seleniumplease中访问url:,在站点中,当鼠标悬停在项目上时,按钮显示。当按钮被禁用时,如何使用SeleniumWebDriver查找按钮?