我正在尝试运行一个测试,在eBay上搜索帐篷,但是在最大化窗口之后测试会停止
package com.xxx.yyy;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class eBay {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "src/main/resources/chromedriver.exe");
WebDriver driver = new ChromeDriver();
mySleep(3);
driver.manage().window().maximize();
String url = "www.ebay.com";
driver.get(url);
driver.findElement(By.className("gh-tb ui-autocomplete-input"));
WebElement textbox = driver.findElement(By.id("gh-ac-box"));
textbox.sendKeys("tent");
mySleep(1);
driver.quit();
}
private static void mySleep(int t) {
try {
Thread.sleep(t * 1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Chrome窗口打开,已最大化,但是接下来什么也没有发生,在Eclipse中,我可以看到此错误:
INFO:检测到的方言:W3C 线程“主” org.openqa.selenium.InvalidArgumentException中的异常:无效参数