UPDATED
The above answer did not work for me. First off, I had to downgrade to selenium driver to 3.4.0 from 3.8.0 (3.8.0 tests would fail when expected a pass, would not find elements or even very basic tests) downgrading to 3.4.0 solved that. Here is a detailed explanation of a setup that does work for me. Yours might be slightly different however this should help out some people.
in this version of selenium driver (3.4.0) you will likely need to specify "marionette": true in the browser capabilities section of your behat.yml , otherwise firefox will load instead of Internet Explorer.
here is a detailed explanation of a setup of Internet Explorer 11 for selenium /behat using recent versions of selenium and behat.
composer.json something like:
{
"name": "test",
"description": "Joe applications",
"type": "project",
"authors": [
{
"name": "Joseph Olstad",
"email": "spam@lol.biz"
}
],
"require-dev": {
"behat/behat": "^3.2.3",
},
"require": {
"lakion/mink-debug-extension": "^1.2",
"behat/mink-selenium2-driver": "^1.1"
}
}
behat.yml as follows:
seleniuminternetexplorer:
suites:
default:
contexts:
- FeatureContext:
parameters:
base_url: "https://google.com"
extensions:
Behat\MinkExtension:
default_session: selenium2
base_url: "https://google.com"
goutte: ~
selenium2: ~
javascript_session: selenium2
browser_name: "internet explorer"
selenium2:
browser: "internet explorer"
wd_host: http://192.168.99.1:4444/wd/hub
capabilities: {"browser": "internet explorer", "version": "11", "marionette": true}
sessions:
my_session:
selenium2:
wd_host: http://192.168.99.1:4444/wd/hub
browser: "internet explorer"
capabilities: {"browser": "internet explorer", "version": "11", "marionette": true}
Lakion\Behat\MinkDebugExtension:
directory: /tmp/debug-ie11
/tmp/debug-ie11 , running behat from a Linux php environment, if on windows you'd have to change this. To make the tests run in the simplest way possible I ended up actually running behat directly on the same windows 7 virtualbox that I installed IEDriverServer.exe on and also ran selenium standalone on the same windows 7 virtualbox as the behat.
either PHP 7.0.x and PHP 5.6.x should do for running behat.
change the 192.168.99.1 to the address of your selenium server that has internet explorer and drivers set up.
Windows 7 32bit setup:
using selenium 3.4.0
32 bit IEDriverServer.exe (3.4.0) on 32 bit windows 7
java -Dwebdriver.ie.driver=C:/windows/IEDriverServer.exe -Dwebdriver.ie.driver.host=127.0.0.1 -Dwebdriver.ie.driver.whitelisted-ips=192.168.99.1,127.0.0.1 -Dwebdriver.ie.driver.loglevel=DEBUG -Dwebdriver.ie.driver.logfile="C:/temp/ie_selenium.log" -jar selenium-server-standalone-3.4.0.jar
I am using java version "1.8.0_121"
in windows powershell you must set up internet explorer registry keys as follows.
New-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\0" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\1" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\2" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\3" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\4" -Name "2500" -Value 0 -PropertyType DWORD -Force
For good measure, do HKLM as well:
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\0" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\1" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\2" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\3" -Name "2500" -Value 0 -PropertyType DWORD -Force
New-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\internet settings\zones\4" -Name "2500" -Value 0 -PropertyType DWORD -Force
set the view to 100% in IE11 , based on documentation from SeleniumHQ wiki for Internet Explorer 11.
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
to debug and figure out what was going on I ended up using debug techniques to dump variables into a text file by putting this in the Selenium2Driver.php
however the marionette option that actually fixes this was the real crux of this , lots of fun along the way getting Internet Explorer and the driver set up. Can debug that using the web interface for selenium, once you have that working, then it's between your behat.yml , the mink selenium2 driver and selenium that you have to get working.
now I'm onto the next step which is to find a way for Internet Explorer to ignore invalid https certificates that we use in our test environments.
I run behat as follows for this config (from another machine, not windows):
behat -p seleniuminternetexplorer
However, I ran into yet another snag , the IEDriverServer crashed, after debugging, figured it it was crashing on deleting all cookies.
so to prevent IEDriverServer.exe from crashing and get IE11 to work with seleniun, I had to disable the Delete all cookies from this part of the php-webdriver:
instaclick/php-webdriver/lib/WebDriver/Session.php
/**
* Delete all cookies: /session/:sessionId/cookie (DELETE)
*
* @return \WebDriver\Session
*/
public function deleteAllCookies()
{
//$this->curl('DELETE', '/cookie');
return $this;
}
so make sure to comment out /disable this line
//$this->curl('DELETE', '/cookie');
see this thread for more details. https://github.com/SeleniumHQ/selenium/issues/5054
also see this thread:
https://groups.google.com/forum/#!topic/selenium-users/Beu-7QFMizk
I also ended up uninstalling a bunch of windows 7 updates and uninstalling a bunch of windows 7 security updates and also uninstalled a service pack, not sure if that is what also helped because version 3.8.0 still didn't work for me, but downgrading to 3.4.0 seems to have resolved the issues for now.
AND, if you need a solution to bypass IE11 self-signed certificate warnings use self-signed certificates for a different domain or website domain name:
diff --git a/behat/features/bootstrap/FeatureContext.php b/behat/features /bootstrap/FeatureContext.php
index 99511e8..7f50579 100644
--- a/behat/features/bootstrap/FeatureContext.php
+++ b/behat/features/bootstrap/FeatureContext.php
@@ -324,6 +324,13 @@ class FeatureContext extends RawMinkContext implements Context, SnippetAccepting
$findName->click();
}
}
+
+ public function imgoingtosaythis($what_im_sayin) {
+ if ($fp = fopen('z_debug_saythis.txt', 'a')) {
+ fwrite($fp, 'debug='.print_r($what_im_sayin, true) . "\n");
+ fclose($fp);
+ }
+ }
/**
* Opens homepage
* Example: Given I am on "/" */
@@ -336,6 +343,13 @@ class FeatureContext extends RawMinkContext implements Context, SnippetAccepting
public function iAmOnHomepage()
{
$this->visitPath('/');
+ try {
+ //WORKAROUND FOR IE11 INCORRECT CERTIFICATE OR CERT WARNING SELF SIGNED INCORRECT DOMAIN
+ $driver = $this->getSession()->getDriver();
+ $driver->executeScript("javascript:try {document.getElementById('overridelink').click();} catch (err) {console.log('probably cert warn already accepted');}");
+ }
+ catch (Exception $e) {
+ $this->imgoingtosaythis($e->getMessage());
+ }
}
/**
* Opens specified page
@@ -349,6 +363,13 @@ class FeatureContext extends RawMinkContext implements Context, SnippetAccepting
public function visit($page)
{
$this->visitPath($page);
+ try {
+ //WORKAROUND FOR IE11 INCORRECT CERTIFICATE OR CERT WARNING SELF SIGNED INCORRECT DOMAIN
+ $driver = $this->getSession()->getDriver();
+ $driver->executeScript("javascript:try {document.getElementById('overridelink').click();} catch (err) {console.log('probably cert warn already accepted');}");
+ }
+ catch (Exception $e) {
+ $this->imgoingtosaythis($e->getMessage());
+ }
}
Now you should be able to get this working as I have.