4 Feb, 2022
Selenium has used different protocols over the years. There is a JSON Wire Protocol, as well the W3C WebDriver protocol. The naming seems to be all over the place.
The latest Selenium version is 4 but that doesn't work with the old IE driver.
The driver that works for me with IE8 is the Selenium 2 IEDriver.exe. This uses the old Selenium 2 protocol which some selenium integrations don't support.
I tried node.js and Python and both of those do work (code later). I tried Go and it didn't.
So, to set this up you'll need:
Enable Protected Mode
option ticket (or unticked actually, they just all have to have the same setting).Unzip the Java install and the IEDriver. Then put IEDriver.exe
in the java/bin
directory. Put selenium-server-standalone-2.53.1.jar
in there too.
To run the server, click Start, then enter cmd
in the Run box.
Now navigate to the Java bin directory using cd path\to\java\bin\
and then run:
java.exe -jar selenium-server-standalone-2.53.1.jar
This will start the Selenium server, which will in turn run IEDriver.exe ready to be connected to by your tests.
If you don't know your VM's IP, you can start another cmd
window and type ipconfig
.
My VM's IP address from the bridged network adapter is 192.168.0.46. So I can access the Selenium server at http://192.168.0.46:4444/wd/hub
. I'll configure webdriver.Remote
with this URL.
Here's the Python code:
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
class PythonOrgSearch(unittest.TestCase):
def setUp(self):
print(webdriver.Remote)
self.driver = webdriver.Remote(
command_executor='http://192.168.0.46:4444/wd/hub',
desired_capabilities={'browserName': 'internet explorer', 'javascriptEnabled': True})
def test_create_delete_repository(self):
self.driver.get(url="http://www.google.com/ncr")
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
Here's the output:
$ sudo apt install -y python3-selenium
$ python3 selen.py
<class 'selenium.webdriver.remote.webdriver.WebDriver'>
.
----------------------------------------------------------------------
Ran 1 test in 5.099s
OK
And here's the node.js code:
const {Builder, By, Key, until} = require('selenium-webdriver');
(async function example() {
let driver = await new Builder().forBrowser('internet explorer')
.usingServer('http://192.168.0.46:4444/wd/hub')
.build();
try {
await driver.get('http://www.google.com/ncr');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
console.log('Pass')
} finally {
await driver.quit();
}
})();
There are of course more modern approaches than Selenium today. For example https://playwright.dev/ but they don't have the legacy browser support of Selenium.
The beauty of the Selenium approach is also that if you write your tests in Python, the same test should work on AWS Device Farm:
https://docs.aws.amazon.com/devicefarm/latest/testgrid/getting-started-local.html
Be the first to comment.
Copyright James Gardner 1996-2020 All Rights Reserved. Admin.