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
Javascript 无法使用Selenium在易趣中向下滚动_Javascript_Selenium_Selenium Webdriver - Fatal编程技术网

Javascript 无法使用Selenium在易趣中向下滚动

Javascript 无法使用Selenium在易趣中向下滚动,javascript,selenium,selenium-webdriver,Javascript,Selenium,Selenium Webdriver,我正在尝试自动测试eBay.com () 在此过程中,我在搜索栏上搜索了Cricket,并在搜索类别中选择了“Sporting Goods”。 在登录到新页面时 我想点击一个标题为“阿迪达斯Pellara Elite XT 1级板球棒”的板球棒,但是我不能这么做 我已经尝试使用JS executor向下滚动到相关项目,但没有成功 public void search() { WebElement searchBox = driver.findElement(By.xpath("//*[@id

我正在尝试自动测试eBay.com

()

在此过程中,我在搜索栏上搜索了Cricket,并在搜索类别中选择了“Sporting Goods”。 在登录到新页面时

我想点击一个标题为“阿迪达斯Pellara Elite XT 1级板球棒”的板球棒,但是我不能这么做

我已经尝试使用JS executor向下滚动到相关项目,但没有成功

public void search() {
  WebElement searchBox = driver.findElement(By.xpath("//*[@id=\"gh-ac\"]"));

  WebElement category = driver.findElement(By.xpath("//*[@id=\"gh-cat\"]"));

  searchBox.sendKeys("Cricket");
  Select category1 = new Select (category);
  category1.selectByVisibleText("Sporting Goods");
  searchBox.sendKeys(Keys.RETURN);
  driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS);   

  WebElement Save_Search = driver.findElement(By.xpath("//*[@id=\"w9-follow-follow-faux-btn\"]"));

  Save_Search.click();
  WebElement Price_Filter = driver.findElement(By.xpath("//*[@id=\"srp-river-results-query_answer1-w0-x-carousel-items\"]/ul/li[3]/div/a/div"));

  Price_Filter.click();
  WebElement Adidas_Pellara_Bat = driver.findElement(By.partialLinkText("adidas Pellara Elite XT Grade 1"));

  js.executeScript("arguments[0].scrollIntoView", Adidas_Pellara_Bat);

  Adidas_Pellara_Bat.click();

 }

如果使用JS Executor向下滚动,则会出现
空指针异常
,否则,我只是得到
没有这样的元素例外
或者网站上的预定义消息说他们没有这个产品

当其他人搜索时,他们可能不会得到
阿迪达斯Pellar Elite XT 1级板球球拍
作为搜索结果。不确定您的意思,先生,如果我使用这个词搜索“阿迪达斯Pellara Elite XT 1级板球棒”,该物品仍在使用中,但我没有找到:(你说得对,先生,当物品的标题仍在那里时,如果我点击标题,它会显示物品丢失。至于实际问题,我找到了一个解决方法,当其他人搜索时,他们可能不会得到列为搜索结果的阿迪达斯Pellara Elite XT Grade 1 Cricket Bat。不确定您的意思,先生,如果我使用该术语搜索”阿迪达斯Pellara Elite XT Grade 1 Cricket Bat”,该项目仍在使用中,因此我没有找到它:(您是对的,先生,虽然该项目的标题仍在使用中,但如果我单击标题,它会显示该项目已丢失。至于实际问题,我找到了解决方法