Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/385.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/3/apache-spark/5.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
Javascript 如何";点击";Amazon上使用Selenium的autosuggestion的某些建议?_Javascript_Java_Selenium_Amazon_Autosuggest - Fatal编程技术网

Javascript 如何";点击";Amazon上使用Selenium的autosuggestion的某些建议?

Javascript 如何";点击";Amazon上使用Selenium的autosuggestion的某些建议?,javascript,java,selenium,amazon,autosuggest,Javascript,Java,Selenium,Amazon,Autosuggest,我正在尝试在amazon.com上自动完成建议。但与谷歌搜索选项不同,建议的xpath总是在变化。我发布的代码并非每次都有效,因为有时所需建议的xpath/id/css选择器正在更改(@id=\“issDiv8\”),有时是“issDiv4”或“issDiv6”等等 WebElement searchTextField=driver.findElement(By.id(“twotabsearchtextbox”); searchTextField.sendKeys(“turbo”); WebD

我正在尝试在amazon.com上自动完成建议。但与谷歌搜索选项不同,建议的xpath总是在变化。我发布的代码并非每次都有效,因为有时所需建议的xpath/id/css选择器正在更改(@id=\“issDiv8\”),有时是“issDiv4”或“issDiv6”等等

WebElement searchTextField=driver.findElement(By.id(“twotabsearchtextbox”);
searchTextField.sendKeys(“turbo”);
WebDriverWait wait=新的WebDriverWait(驱动程序,20);
wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(“/*[@id=\”issDiv8\“]));
列出autoSuggest=driver.findElements(By.xpath(“/*[@id=\“issDiv8\”]);
System.out.println(“自动建议列表::”+autoSuggest.size());
对于(int i=0;i
使用
WebdriverWait
处理动态元素,并使用以下
xpath

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@data-keyword='turbotax']")));
element.click()

关于“数量”,我有几乎相同的问题当我想买东西的时候。我应该做一个新的话题还是可以在这里问?@Alex:这应该是不同的问题。这是一个特定问题的解决方案,可以供未来的读者使用。如果你在一篇博文中问了多个问题,可能看不到这个答案。谢谢。欢迎使用堆栈溢出!请避免使用第三方服务s以显示图像。如果需要添加图像,请在编辑时单击图像按钮将其添加到帖子中,或者复制图像并单击CTRL+V,或者以任何其他方式将其直接粘贴到帖子中。第三方图像服务,或者留下死链接,或者URL可用于恶意目的。
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@data-keyword='turbotax']")));
element.click()