最初我使用chrome开发网页抓取来从所需的网站上抓取数据,所以现在我想将这个java应用程序转换为REST服务,
以下是我的代码,执行时收到“Is there any way of detecting through changes in the onUpdated event or in any other event to precisely detect the event of the page getting refreshed in a particular tab
”
unable to open resource url make sure the project has been deployed successfully and the server is running
收到“ @GET
@Produces("text/plain")
public String getText() throws InterruptedException {
WebDriver driver;
File file = new File("resources/chromedriver.exe");
String absolutePath = file.getAbsolutePath();
System.setProperty("webdriver.chrome.driver", absolutePath);
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
options.addArguments("window-size=1200x600");
driver = new ChromeDriver(options);
Thread.sleep(2000);
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://google.com");
WebDriverWait wait = new WebDriverWait(driver,
timeoutInSeconds);
wait.until((ExpectedCondition<Object>) new ExpectedCondition<Object>() {
@Override
public Object apply(@Nullable WebDriver input) {
WebElement divProgress = input.findElement(By
.id("phasesTableContainer"));
return divProgress;
}
});
Thread.sleep(3000);
String price = driver.findElement(By.xpath("//span[@data-dojo-attach-point='price']")).getText();
return price;
来自服务器(玻璃鱼) -
unable to open resource url make sure the project has been deployed successfully and the server is running
注意:我是新手(REST服务),请指导我 下面的问题
Info: Initiating Jersey application, version Jersey: 2.0 2013-05-03 14:50:15...
Warning: StandardWrapperValve[com.fee.ApplicationConfig]: Servlet.service() for servlet com.fee.ApplicationConfig threw exception
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:33)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:139)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:335)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
at com.usfee.MyPathResource.getText(MyPathResource.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)