我刚开始学习硒WD。我正在使用firefox,& java 1.8&在我的Mac中蚀。在下面的代码中,我试图打印最低价格值 orbitz.com网站。
当我等到代码的末尾时,它会卡住&不回来。我无法弄清楚为什么&需要一些帮助来解决这个问题。
package fh2_orbitzWD;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class WDDemo1 {
public static void main(String[] args) throws InterruptedException,
IOException{
WebDriver wd = new FirefoxDriver();
wd.get("http://www.orbitz.com");
wd.findElement(By.xpath("//input[@name='search.type']")).click();
//Thread.sleep(1000);
WebDriverWait wait = new WebDriverWait(wd,60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name
("ar.rt.leaveSlice.orig.key")));
wd.findElement(By.name("ar.rt.leaveSlice.orig.key")).clear();
wd.findElement(By.name("ar.rt.leaveSlice.orig.key")).sendKeys("DFW");
wd.findElement(By.name("ar.rt.leaveSlice.dest.key")).clear();
wd.findElement(By.name("ar.rt.leaveSlice.dest.key")).sendKeys("SFO");
wd.findElement(By.name("ar.rt.leaveSlice.date")).clear();
wd.findElement(By.name("ar.rt.leaveSlice.date")).sendKeys("5/15/2015");
wd.findElement(By.name("ar.rt.returnSlice.date")).clear();
wd.findElement(By.name("ar.rt.returnSlice.date")).sendKeys("5/25/2015");
System.out.println("Right before the click of search");
wd.findElement(By.name("search")).click();
WebDriverWait wait2 = new WebDriverWait(wd,80);
wait2.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*
[@id='resultsTwoColumn']")));***
String price = wd.findElement(By.xpath("//span[@class='money small-
cents']")).getText();
System.out.println("Price is: " + price);
}
}