我正在尝试使eBay.com的测试自动化
(https://www.ebay.com/sch/i.html?_from=R40&_nkw=Cricket&_sacat=888&_udlo=3536)
在此过程中,我在搜索栏上搜索了板球,然后在搜索类别中选择了“运动用品”。 进入新页面后
我想单击标题为“ adidas Pellara Elite XT 1级板球拍”的板球拍,但是无法这样做
我已经尝试使用JS执行器向下滚动到相关项目,但这没用
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向下滚动,我会得到Null Pointer Exception
,否则,我只是得到No Such Element Exception
或网站上的预定义消息,说他们没有此产品