Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.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自动单击直到旋转木马结束_Java_Selenium_Selenium Webdriver_Jcarousel - Fatal编程技术网

Java 使用selenium webdriver自动单击直到旋转木马结束

Java 使用selenium webdriver自动单击直到旋转木马结束,java,selenium,selenium-webdriver,jcarousel,Java,Selenium,Selenium Webdriver,Jcarousel,我想单击旋转木马的下一个箭头,直到循环结束。现在,如何使用selenium webdriver不断单击下一个箭头?? 我在点击中做了for循环,但它不起作用。 这是元素的基本代码,请单击 element = driver.findElement(By.xpath(".//*[@id='hp_category_tab_electronics_0-content']/div[1]/div/div/a[2]")); element.click(); 所以简而言之,在遇到产品结束之前,我想点击下一个箭

我想单击旋转木马的下一个箭头,直到循环结束。现在,如何使用selenium webdriver不断单击下一个箭头?? 我在点击中做了for循环,但它不起作用。 这是元素的基本代码,请单击

element = driver.findElement(By.xpath(".//*[@id='hp_category_tab_electronics_0-content']/div[1]/div/div/a[2]"));
element.click();
所以简而言之,在遇到产品结束之前,我想点击下一个箭头按钮5次

element=driver.findElement(By.xpath(“./*[@id='hp\u category\u tab\u electronics\u 0-content']/div[1]/div/div/a[2]”);
element = driver.findElement(By.xpath(".//*[@id='hp_category_tab_electronics_0-content']/div[1]/div/div/a[2]"));
element.click();
for(int i=0;i<4;i++);{
        Thread.sleep(500);
        element.click();
    }
元素。单击();
对于(inti=0;更好的解决方案是使用WebDriverWait wait=newwebdriverwait(driver,5000);wait.until(ExpectedConditions.elementtobelickable((By.xpath(“xpath”)));而不是Thread.sleep(500);