【发布时间】:2019-07-22 16:13:03
【问题描述】:
我在 Eclipse 中有以下代码。我正在尝试在 Chrome 中执行它。在点击 ID #divpaxinfo 之前它可以正常工作,但它不会添加成年人的数量。在 IE 上,它什么也不做。它只是打开网页并停止导航。我一直在努力知道问题出在哪里,但我的结果似乎没有错。可能是什么问题?
package testProject2;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ById;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
public class test2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "C:\\Users\\bk0107\\Documents\\QA\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://spicejet.com");
driver.findElement(By.id("divpaxinfo")).click();
/*int i=1;
while(i<5)
{
driver.findElement(By.id("hrefIncAdt")).click();//4 times
i++;
}*/
System.out.println(driver.findElement(By.id("divpaxinfo")).getText());
for(int i=1;i<5;i++)
{
driver.findElement(By.id("hrefIncAdt")).click();
}
driver.findElement(By.id("btnclosepaxoption")).click();
System.out.println(driver.findElement(By.id("divpaxinfo")).getText());
}
}
【问题讨论】:
-
您能否尝试提供的答案,如果您有任何疑虑,请告诉我?
标签: selenium google-chrome internet-explorer webdriver