I am trying to navigate to www.google.com
and send some inputs to search box using Selenium webdriver with Internet Explorer(IE).
static WebDriver webDriver = null;
static DesiredCapabilities IEDesiredCapabilities = DesiredCapabilities.internetExplorer();
System.setProperty("webdriver.chrome.driver", TestConstants.chromeDriverFilePath);
System.setProperty("webdriver.ie.driver", TestConstants.IEDriverFilePth);
IEDesiredCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true);
webDriver = new InternetExplorerDriver(IEDesiredCapabilities);
//webDriver = new ChromeDriver();
webDriver.navigate().to("http://www.google.com");
webDriver.findElement(By.name("q")).sendKeys("Venkatesh Kolisetty");
//webDriver.findElement(By.id("lst-ib")).sendKeys("Venkatesh Kolisetty");
This piece of code runs very well when i use Chrome, but throws org.openqa.selenium.NoSuchElementException
when IE is used.
This opens required web page in the IE browser which is opened by selenium. The problem is selenium is not able to find any element after page is loaded only when IE is used. For chrome, it finds required elements.
Is there any capability to be added in IEDesiredCapabilities
Kindly see the possibility of providing a programmatic solution instead of changing internet options manually.
Yes this is common issue when you use IE.
Open regedit.exe
Open HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
So Zones will contain 0,1,2,3,4 and on right hand side three columns will be visible as soon as you click on 0 i.e. Name Type Data
Now in Name column look for 2500 Double click it. Put Value data as 3 and Base as Hexadecimal
You did this for 0.
Now repeat the same steps for 1,2,3,4..
Do this for all i.e. 0,1,2,3,4,5 => Change all 2500's value data to 3.
After that run this code.
It will run on IE. You need a IEDriverServer.exe as i have shown in path, which will run your IE browser.
Reply to me for further query. I ran the above code in eclipse and it ran successfully.
Happy learning :-)
Issue resolved after adding some required capabilities.
IEDesiredCapabilities.setCapability("requireWindowFocus", true);
is optional