可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I downloaded the driver and I gave the exact path in my code but when I ran the code it shows me error
my code with java is as below:
System.out.println("Internet Explorer is selected");
System.setProperty("webdriver.ie.driver","C:\\Program Files\\Selenium\\Drivers\\IEDriver\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
selenium = new WebDriverBackedSelenium(driver, "http://www.datamoat.com/");
and the error message is
org.openqa.selenium.remote.SessionNotFoundException: 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 (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.15 seconds
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'SAKIB-PC', ip: '192.168.10.70', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
回答1:
It needs to set same Security level in all zones. To do that follow the steps below:
1.Open IE
2.Go to Tools -> Internet Options -> Security
3.Set all zones (Internet, Local intranet, Trusted sites, Restricted sites) to the same protected mode, enabled or disabled should not matter.
Finally, set Zoom level to 100% by right clicking on the gear located at the top right corner and enabling the status-bar. Default zoom level is now displayed at the lower right.
回答2:
I think you have to make some required configuration to start and run IE properly. You can find the guide at: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
回答3:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.*;
public class IEclass {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver","S:\\IE and Chrome ServerDriver\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("https://www.google.com");
}
}
回答4:
I've been firefighting with this issue for the past one month. And finally I found a fruitful solution. Here are the exact steps which we followed to get it worked. I have already done Required Configuration as mentioned in this link: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration
- Make the internet explorer protected mode settings enable/disable for all the zones. (In my case I enabled across all the zones, doesn't matter about the levels). If your organisation not allow these settings, the other solution is to create a group at active directory level and enforce our expected internet explorer settings for that group. Add your user name to that group.
- Install IE Webdriver tool for windows from the below link. This is from Microsoft. No need to restart your machine after installation
https://www.microsoft.com/en-au/download/details.aspx?id=44069
Use these Desired Capabilities for your internet explorer driver
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability("requireWindowFocus", true);
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, false);
capabilities.setCapability("ie.ensureCleanSession", true);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(InternetExplorerDriver.FORCE_CREATE_PROCESS, true);
webDriver = new InternetExplorerDriver(capabilities);
Use appropriate selenium version 2.53.1. I got it worked for the selenium version as mentioned in pom
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
Download the IEDriverServer_x64_2.53.1.zip from the below link. Make sure its 2.53.1
http://selenium-release.storage.googleapis.com/index.html?path=2.53/
Now go to registry settings (regedit.exe)
for the current user (Don't open regedit
as an Administrator) and add TabProcGrowth for the below path in regedit
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
Right click on Main and add new DWORD (32 bit) and make it as 0. Remember I tried 64 bit with QWORD it didn't worked for me.
The key in this process is Step 2 which is Install IE Webdriver tool for windows
I didn't tried this method for Selenium latest version 3.0 but will give a try.
回答5:
In the same way for Chrome Browser below are the things to be considered.
Step 1-->Import files Required for Chrome :
import org.openqa.selenium.chrome.*;
Step 2--> Set the Path and initialize the Chrome Driver:
System.setProperty("webdriver.chrome.driver","S:\\chromedriver_win32\\chromedriver.exe");
Note: In Step 2 the location should point the chromedriver.exe file's storage location in your system drive
step 3--> Create an instance of Chrome browser
WebDriver driver = new ChromeDriver();
Rest will be the same as...
回答6:
First download the exe file of the IEDriverServer (64 bit and 32 bit).
Don't need to install, only download this file with your browser( 64 or 32 bit)
and simply give the path of the exe file in the given code.
http://www.seleniumhq.org/download/
use this code
package myProject;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Browserlaunch {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "C:/Drivers/IEDriverServer.exe");
InternetExplorerDriver IEDriver=new InternetExplorerDriver();
IEDriver.get("http://localhost:8888");
}
}
回答7:
In c#, This can bypass changing protected zone settings.
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Bottom;
回答8:
- You must set Protected Mode settings for each zone to be the same value.
- Enhanced Protected Mode for all zones must be same. (I prefer it to be disabled as this is the requirement for IE 10 and higher.)
Additionally, "Enhanced Protected Mode" must be disabled for IE 10 and higher. This option is found in the Advanced tab of the Internet Options dialog.
How to do above steps???
Have look at this video: http://screencast.com/t/5nlxsrje4I . I have showed the steps.
Source: https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration
Hope this helps. Thank you :)
回答9:
static WebDriver driver;
System.setProperty("webdriver.ie.driver","C:\\(Path)\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.get("EnterURLHere");
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
回答10:
1---Enable protected mode for all zones
You need to enable protected mode for all zones from Internet Options -> Security tab. To enable protected mode for all zones
Open Internet Explorer browser.
Go to menu Tools -> Internet Options.
Click on Security tab.
Select Internet from "Select a zone to view or change security settings" and Select(check) check box "Enable Protected Mode" from In the "Security level for this zone" block .
Apply same thing for all other 3 zones -> Local Internet, Trusted Sites and Restricted Sites
This setting will resolve error related to "Protected Mode settings are not the same for all zones.
2-- Set IE browser's zoom level 100%
Open Internet Explorer browser.
Go to menu View -> Zoom -> Select 100%
回答11:
Below steps are worked for me, Hope this will work for you as well,
- Open internet explorer.
- Navigate to Tools->Option
- Navigate to Security Tab
- Click on "Reset All Zones to Default level" button
- Now for all option like Internet,Intranet,Trusted Sites and Restricted Site enable "Enable Protected" mode check-box.
- Set IE zoom level to 100%
then write below code in a java file and run
System.setProperty("webdriver.ie.driver","path of your IE driver exe\IEDriverServer.exe");
InternetExplorerDriver driver=new InternetExplorerDriver();
driver.manage().window().maximize();
Thread.Sleep(10100);
driver.get("http://www.Google.com");
Thread.Sleep(10000);
回答12:
To run test cases in IE Browser make sure you have downloaded IE driver and you need to set the property as well.
Below code will help you
// This will set the driver
System.setProperty("webdriver.ie.driver","driver path\\IEDriverServer.exe");
// Initialise browser
WebDriver driver=new InternetExplorerDriver();
You can check IE Browser challenges with Selenium and complete code for more details
回答13:
Go to Tools -> Internet Options -> Security and Enable protection mode for all zones. It worked for me :)