Trying to Run a Script in Luna Eclipse using IE Driver
and getting the following error:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Here is the code trying to Run:
package com.newpack;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class SecondClass {
public static void main(String[] args)
{
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("requireWindowFocus", true);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL,"https://www.google.co.in");
System.setProperty("webdriver.ie.driver","M:\\workspace\\IEDriver.exe");
WebDriver driver ;
driver = new InternetExplorerDriver(capabilities);
String baseUrl = "https://www.google.co.in";
driver.get(baseUrl);
String expectedTitle = "Google";
String actualTitle = "";
actualTitle = driver.getTitle();
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
driver.close();
System.exit(0);
}
}
try once following steps
Got to
internet options>>Security>>
click on:"Reset all zones to default level"
ensure that the 'Enable protected mode' checkbox is ticked for all the four zones. Like i.e Internet, Local internet, Trusted Sites, Restricted Sites.
Internet Explorer needs to be configured first in order to successfully run a selenium script.
Make sure you complete all the following steps:
Go to Internet Options > Security and enable "Protected Mode" for all the 4 zones: Internet, Local internet, Trusted Sites, Restricted Sites.
Also, click on Custom Level for all 4 zones and reset Recent Custom Settings to same level, say "Medium" or "High".
If this does not work, please update your IEDriverServer from Selenium Official Downloads
Related
I am using Internet Explorer driver 4.0.0(32bit) and selenium updated version 4.1.2when I run the code using Internet Explorer driver 4.0.0 it is stuck at This is the initial start page for the WebDriver server.
even though I check the setting in Internet Explorer:
All the protected mode is disabled
zoom setting is 100% for Internet Explorer and windows also
enchanted protected mode is off
but when I change the Internet Explorer driver to 3.1.4 it works fine. I also tried the Internet Explorer 4.0.0 for 64 but the same issue I am facing please help me.
public class EdgeTest {
static RemoteWebDriver driver = null;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.ie.driver",
"D:\\Automation\\Jar Details\\Drivers\\IEDriverServer_Win32_4.0.0\\IEDriverServer.exe");
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.attachToEdgeChrome();
ieOptions.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
ieOptions.setCapability("ignoreProtectedModeSettings", true);
ieOptions.setCapability("ignoreZoomSettings",true);
System.out.println("this:"+ieOptions.getCapability("ignoreZoomSettings"));
driver = new InternetExplorerDriver(ieOptions);
InternetExplorerDriverService.createDefaultService();
driver.get("https://github.com/");
WebElement elem = driver.findElement(By.name("q"));
elem.sendKeys("gitu");
elem.sendKeys(Keys.ENTER);
driver.quit();
error: "Could not create a new remote session" this is an error
getting
It looks like you are using selenium webdriver to automate Edge IE mode. I tried executing your code and I found this code to work fine (using IE driver 4.0.0 and Selenium 4.1.2).
But when executing code again before the code has not been executed complete, you get the same problem you describe (execute code twice at once). like this:
So I think when the IE driver may be occupied, you can try to open the task manager, end the related task (IE driver 32 bit), and then re-execute the code, I think this should be useful to you.
I tried to use the following code to open a URL in my local system. But I get error message as shown in screen shot.
Code
package First_test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class first_case {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();
//Launch the Website
driver.get("http://127.0.0.1:3000");
// Print a Log In message to the screen
System.out.println("Successfully opened the website ");
// Close the driver
driver.quit();
}
}
error message
What shall I do to solve this problem? Thanx!
You need to install gecko driver. A brief introduction about it and how to install gecko driver can be found in following link. Hope this helps!
Gecko Driver is the link between your tests in Selenium and the Firefox browser
http://toolsqa.com/selenium-webdriver/how-to-use-geckodriver/
I installed gecko driver from github and put it in the folder location of my workplace and it worked!
working result
Download geckodriver and use this code:
System.setProperty("webdriver.gecko.driver", "E:/software and tools/geckodriver.exe");
WebDriver driver= new ChromeDriver();
//Launch the Website
driver.get("http://127.0.0.1:3000");
// Print a Log In message to the screen
System.out.println("Successfully opened the website ");
// Close the driver
driver.quit();
I am trying to Open IE using webDriver and getting following error:
Unexpected error launching Internet Explorer. Protected Mode settings
are not the same for all zones. Enable Protected Mode must be set to
the same value
I have checked the Security Protected mode on for IE as suggested by other threads on the same matter. Also Zoom level is set to 100%
Still having the same issue.
Following is my code snippet:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Browser {
public static WebDriver driver = null;
public static void main(String[] args) {
Driver("IE");
driver.get("http://google.co.uk");
driver.quit();
}
public static WebDriver Driver(String Driver_Type){
if(Driver_Type.equalsIgnoreCase("FF")){
driver = new FirefoxDriver();
}
else if(Driver_Type.equalsIgnoreCase("Chrome")){
System.setProperty("webdriver.chrome.driver", "D:\\Selenium Stuff\\Browser drivers\\chromedriver.exe" );
driver = new ChromeDriver();
}
else if(Driver_Type.equalsIgnoreCase("IE")){
System.setProperty("webdriver.ie.driver", "D:\\Selenium Stuff\\Browser drivers\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
return driver;
}
}
Could you kindly help me on this??
So after you change the protection setting and zoom level, it's still the same error popped out? or it becomes a different error? If you're using IE9, you may need to check this link eselenium-ieserverdriver-not-finding-new-windows-for-ie9 and it turns out enabling the compatibility mode solves the problem.
This is a very frequently asked question on the forum.
The solution is to disable the protected mode in the Internet explorer settings.
Steps to disable the protected mode:
Open Internet Explorer -> Settings -> Security Tab
There you will find 4 categories (Internet, Local Intranet, Trusted Sites, Restricted Sites)
Click on one of them to find the "Check Box" Enable Protected Mode. Make sure the field is "Unchecked".
Make sure that Protected mode is all the zones.
This will solve your issue.
More Details can be found on https://code.google.com/p/selenium/issues/detail?id=1795
I am using the following code to run chrome driver:
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestClass
{
public static void main(String[] args){
System.setProperty("webdriver.chrome.driver", "/Users/raisa/Documents/Selenium/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
driver.quit();
}
}
But I am getting this error:
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /Users/raisa/Documents/Selenium/chromedriver.exe
at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:117)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:112)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:117)
at TestClass.main(TestClass.java:11)
I have downloaded the latest chrome driver from http://chromedriver.storage.googleapis.com/index.html
I agree with the comments.
On Mac OS you will not need .exe after chromedriver.
For your example you'll want it to look like this: /Users/raisa/Documents/Selenium/chromedriver.
I've also seen this problem come up because the execute permissions wasn't set for the file.
So double check the file permissions, and also that the file is in the actual path given.
Through terminal navigate to the place where chromedriver is located and then execute following command.
xattr -d com.apple.quarantine chromedriver
I have written the following code and downloaded PhantomJS intot he specified folder on c:\ but am getting the error: "Unable to connect to remote server ...". Here is the code I wrote:
[TestMethod]
public void HeadlessBrowser()
{
IWebDriver driver = new PhantomJSDriver("C:\\trashStuff\\phantomjs-1.9.0-windows"); //or some other driver
driver.Navigate().GoToUrl("http://yahoo.com");
// Lets take a screenshot to really make sure we did visit the site above
Console.WriteLine("Take A screen shot");
Screenshot myScreenShot = ((ITakesScreenshot)driver).GetScreenshot();
myScreenShot.SaveAsFile("c:\\trashStuff\\screenshot.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
// after the run, go to the location above and find screenshot.jpg
}
Download PhantomJS or add it to your project using NuGet Package Manager. I got it using NuGet and didn't have to put the path to the driver as one of the parameters in PhantomJSDriver class.
var driver = new PhantomJSDriver();