【发布时间】:2018-12-21 23:20:54
【问题描述】:
我在 Eclipse 中有一些具有以下结构的代码:
package automationFramework;
import java.util.List;
import org.openqa.selenium.support.ui.Select;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirefoxDropDown {
public static void main(String[] args) throws InterruptedException {
// Create a new instance of the Firefox driver
System.setProperty("webdriver.gecko.driver", "/home/gradulescu/Documents/Eclipse project/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// Storing the Application URL in the String variable
String url= "http://toolsqa.wpengine.com/automation-practice-form/";
driver.get(url);
//Launch the Online Store Website
Select oSdropDown = new Select((WebElement)driver.findElement(By.id("continents")));
oSdropDown.selectByIndex(1);
Thread.sleep(100);
oSdropDown.selectByVisibleText("Africa");
Thread.sleep(100);
List<WebElement> oSize = oSdropDown.getOptions();
int size = oSize.size();
for(int i=0;i<size;i++)
{
String sValue = oSdropDown.getOptions().get(i).getText();
System.out.println(sValue);
}
driver.quit();
}
}
我的期望是在第一个代码运行后,等待 10 秒,然后是第二个代码,再等 10 秒。但实际上编译器在命令后运行命令而不等待我设置的 10 秒。
它是否有任何强制条件才能工作?
谢谢!
【问题讨论】:
-
不要假设库方法的作用。阅读它的 javadoc。它说 毫秒。
-
那么:这与您在此处使用的大多数标签没有任何关系。请仅使用有意义的标签。您选择的 IDE 肯定与编程问题无关。