0

I have some code with the following structure in 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();

    }   
}

My expectation would be that after the first code ran, 10 seconds to be waited and then the second code and some other 10 seconds. But actually the compiler runs command after command without waiting the 10 seconds I have set.

Is there any mandatory condition for it to work?

Thank you!

GhostCat
  • 137,827
  • 25
  • 176
  • 248
Gabriela R
  • 37
  • 1
  • 4
  • 2
    Dont **assume** what a library method does. Read its javadoc. It says **milliseconds**. – GhostCat Jul 13 '18 at 14:38
  • 1
    Then: this has *nothing* to do with most of the tags you are using here. Please use only tags that are meaningful. Your choice of IDE is for sure not relevant for a programming problem. – GhostCat Jul 13 '18 at 14:38

1 Answers1

0

I don't think you're waiting long enough, try: Thread.sleep(10000);

You can also use: Thread.sleep(TimeUnit.SECONDS.toMillis(10));

Hmax
  • 314
  • 6
  • 16