0

I am new to Selenium. I just want to send keys to a username text box through internetexplorer using the below code;

Here is the code:

public class IE_Brower {
    public static void main(String[] args) {    
        System.setProperty("webdriver.ie.driver", "Driver/IEDriverServer.exe");
        WebDriver driver = new InternetExplorerDriver();
        driver.get("https://www.facebook.com");
        driver.findElement(By.id("email")).sendKeys("Testing");
    }
}

But only facebook page is getting open but value in the text field is not passing. This one is not working. Please help me.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
vishal saxena
  • 25
  • 1
  • 4

2 Answers2

0

My guess is that the page takes time to load and before it loads, it tries to find "email" element and it could not found that as page hasn't loaded completely.

The solution would be to wait till the particular element is visible and then sendKeys to it like -

WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("email")));
driver.findElement(By.id("email")).sendKeys("Testing");

This will wait till the email element is visible & loaded before you send some input to it.

gohil90
  • 517
  • 5
  • 16
  • Thanks for your response but problem was the setting of the IE. Please see the below video for the setting of the IE -> youtube.com/watch?v=OuW_Yv9SiNk – vishal saxena Jan 13 '18 at 10:29
0

Code looks fine for me. Just make sure that you have latest IEDriverServer.exe and proper 32/64 bit IEDriverServer.exe with respect to your locally installed Internet Explorer browser.

Pradeep hebbar
  • 2,147
  • 1
  • 9
  • 14
  • Thanks for your response but problem was the setting of the IE. Please see the below video for the setting of the IE -> https://www.youtube.com/watch?v=OuW_Yv9SiNk – vishal saxena Jan 13 '18 at 10:28