Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

About the problems encountered in Selenium self-study

Shulou Source: shulou.com Published: 2022-06-03 05:19:04 09月16日 Update

The time code for launching ie browser in 1.selenium (in the red box) is as follows:

When you click run, the console reports an error as follows:

Started InternetExplorerDriver server (64-bit)

2.53.0.0

Listening on port 31574

Only local connections are allowed

Exception in thread "main" 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: 692 milliseconds

Build info: version: '2.53.0mm, revision:' 35ae25bund, time: '2016-03-15 16V 5740'

System info: host: 'XL-20150414QGDQ', ip:' 192.168.80.6, os.name: 'Windows 7, os.arch:' amd64', os.version: '6.1, java.version:' 1.7.080'

Driver info: org.openqa.selenium.ie.InternetExplorerDriver

At sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)

At sun.reflect.NativeConstructorAccessorImpl.newInstance (Unknown Source)

At sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Unknown Source)

At java.lang.reflect.Constructor.newInstance (Unknown Source)

At org.openqa.selenium.remote.ErrorHandler.createThrowable (ErrorHandler.java:206)

At org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed (ErrorHandler.java:158)

At org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:678)

At org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java:249)

At org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java:234)

At org.openqa.selenium.ie.InternetExplorerDriver.run (InternetExplorerDriver.java:182)

At org.openqa.selenium.ie.InternetExplorerDriver. (InternetExplorerDriver.java:174)

At org.openqa.selenium.ie.InternetExplorerDriver. (InternetExplorerDriver.java:146)

At Project1Class.main (Project1Class.java:13)

Solution:

There are two solutions, one is to change the setting of IE, do not use protected mode (protected mode) under any circumstances, and the other is to set the Capabilities of IE at run time in the following snippet in the previous code.

The added code is as follows:

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer ()

IeCapabilities.setCapability (InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true)

WebDriver driver = new InternetExplorerDriver (ieCapabilities)

The error message can be found at the following address: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.

The latest version can be downloaded from http://selenium-release.storage.googleapis.com/index.html

two。 About the positioning method of the drop-down box:

Method 1: if the drop-down box is the native select of html, you can use the select method of selenium to locate it, but if it is a drop-down box developed by yourself, you cannot use this method.

Select selectCategory1 = new Select (driver.findElement (By.id ("category_1")

SelectCategory1.selectByVisibleText ("java")

Select selectCategory2 = new Select (driver.findElement (By.id ("category_2")

SelectCategory2.selectByVisibleText (3D Games)

Select selectCategory3 = new Select (driver.findElement (By.id ("difficulty")

SelectCategory3.selectByVisibleText ("intermediate")

Otherwise, the following error will be reported:

3. With regard to the positioning of the text box in the editor, we can not find any locatable elements, which need to be solved.

Tags: Method location drop-down error run problem code information element descendant address situation console text is in mode browser fragment editor will report Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Xiaomi OPPO Reno Shulou Information Shulou Technology