Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.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 当我以常规运行方式运行脚本时,它不会';t单击该元素_Java_Selenium_Automation_Cucumber - Fatal编程技术网

Java 当我以常规运行方式运行脚本时,它不会';t单击该元素

Java 当我以常规运行方式运行脚本时,它不会';t单击该元素,java,selenium,automation,cucumber,Java,Selenium,Automation,Cucumber,当我在常规运行中运行脚本时,它不会单击元素,而当我在调试模式下运行脚本时,它会单击。我试着让waitWebDriverWait wait=newwebdriverwait(driver,20);等待。直到(预期条件。元素定位的可视性(elem)),线程睡眠(60000) 它不起作用 public void selectBrand(String brandName) { int i = 0; try { waitElementUntilVisible(dri

当我在常规运行中运行脚本时,它不会单击元素,而当我在调试模式下运行脚本时,它会单击。我试着让wait
WebDriverWait wait=newwebdriverwait(driver,20);等待。直到(预期条件。元素定位的可视性(elem)),线程睡眠(60000)

它不起作用

    public void selectBrand(String brandName) {
    int i = 0;
    try {
        waitElementUntilVisible(driver, brandList);
        WebElement allButton = driver.findElement(brandList);
        List<WebElement> getButton = allButton.findElements(By.className("srn-brand-list-item"));
        List<WebElement> getName = allButton.findElements(By.className("srn-brand-list-name"));
        for (WebElement brand : getName) {
            String name = brand.getText();
            if (name.equalsIgnoreCase(brandName)) {

                JavascriptExecutor executor = (JavascriptExecutor)driver;
                executor.executeScript("arguments[0].click();", getButton.get(i));
            }
            i = i + 1;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
public void selectBrand(字符串brandName){
int i=0;
试一试{
waitElementUntilVisible(驱动程序、品牌列表);
WebElement allButton=driver.findElement(品牌列表);
List getButton=allButton.findElements(By.className(“srn品牌列表项”);
List getName=allButton.findElements(By.className(“srn品牌列表名”);
for(WebElement品牌:getName){
字符串名称=brand.getText();
if(名称.相等信号案例(品牌名称)){
JavascriptExecutor executor=(JavascriptExecutor)驱动程序;
executor.executeScript(“参数[0]。单击();”,getButton.get(i));
}
i=i+1;
}
}捕获(例外e){
e、 printStackTrace();
}
}

它是什么网页?什么元素?是javascript执行器的点击吗?我想您已经尝试过正常的单击了?是的,我尝试过getButton.get(I).click()并且它在调试模式下都能工作