EdgeWebDriver
EdgeWebDriver copied to clipboard
Ability to pass user data directory argument to IEDriverServer for use automating Edge legacy mode
Currently, as far as I can see there is no way to add options to the Edge browser instance that is launched when using IEDriverServer to automate Edge Legacy mode. This means that you are unable to pass a 'user-data-dir' parameter to the Edge browser window (as you can when using msedgedriver), which means my organisations' profile sign in window appears. This causes any automation to fail when automating Edge legacy mode.
Please note that this profile sign in window only appears when using IEDriverServer version 4.0.0 and above, which is mentioned as a pre-requisite by Selenium for Edge legacy automation. If I use a version less than 4.0.0, such as 3.150.1.2, then this window does not appear.

Thank you for filing this issue. It appears this was broken when IEDriver 4.0.0+ started creating a temporary user data directory for every session. The older version didn't do this. I've added this to our internal backlog for consideration.
I have also come across this issue. This is related to pull request link.
The problem code is found in selenium/cpp/iedriver/BrowserFactory.cpp See the function,
void BrowserFactory::LaunchEdgeInIEMode
....
// create a temporary directory for IEDriver test
std::wstring temp_dir;
if (CreateUniqueTempDir(temp_dir)) {
LOG(TRACE) << L"Using temporary folder " << LOGWSTRING(temp_dir) << ".";
executable_and_url.append(L" --user-data-dir=" + temp_dir);
this->edge_user_data_dir_ = temp_dir;
}
I initially posted on the Selenium github, and I was directed here link
I was able to get around this issue with some edits to the browser factory code. I have provided some of the surrounding code so that you can ctrl-f to the relevant section.
// These flags force Edge into a mode where it will only run MSHTML
executable_and_url.append(L" --ie-mode-force");
executable_and_url.append(L" --internet-explorer-integration=iemode");
// THIS IS NEW
// create a temporary directory for IEDriver test if --user-data-dir is not already
// supplied
std::wstring temp_dir;
if (StringUtilities::ToString(browser_command_line_switches_).find("--user-data-dir") == std::string::npos) {
if (CreateUniqueTempDir(temp_dir)) {
LOG(TRACE) << L"Using temporary folder " << LOGWSTRING(temp_dir) << ".";
executable_and_url.append(L" --user-data-dir=" + temp_dir);
this->edge_user_data_dir_ = temp_dir;
}
}
executable_and_url.append(L" --no-first-run");
executable_and_url.append(L" --no-service-autorun");
executable_and_url.append(L" --disable-sync");
executable_and_url.append(L" --disable-features=msImplicitSignin");
executable_and_url.append(L" --disable-popup-blocking");
// THIS IS NEW
if (this->browser_command_line_switches_.size() != 0) {
executable_and_url.append(L" ");
executable_and_url.append(this->browser_command_line_switches_);
}
executable_and_url.append(L" ");
executable_and_url.append(this->initial_browser_url_);
LOG(TRACE) << "IE starting command line is: '"
<< LOGWSTRING(executable_and_url) << "'.";
I also make sure that when adding arguments in python, I put the variables in double quotes.
ieOptions.add_argument('--user-data-dir="'+msedge_user_profile + '"')
ieOptions.add_argument('--profile-directory="Default"')
For almost 2 years this absurd problem persists for which it is not possible to indicate which profile to use while using Edge via WebDriver. Do you have any news about it? The documentation says it works but it's not true...
You are causing problems for tons of Test Automation developers, while Chrome and Firefox support it without problems!
Here are other threads talking about it, but StackOverflow is full of angry people too!
https://answers.microsoft.com/en-us/microsoftedge/forum/all/how-can-you-set-the-default-profile-in-the-new/ca600054-0c46-426e-92e2-2c071a13a623
Now the state of bug is changed in "This conversation has been locked and limited to collaborators." on https://github.com/SeleniumHQ/selenium/issues/10968
PS) Here is the Java code that does not work, however, after trying all the possible variants or various indications (with or without -, with or without double quotes).
EdgeOptions edgeOptions = new EdgeOptions (); String userDataDir = QAUtils.getProperty ("browser.edge.user-data-dir"); String userProfileDir = QAUtils.getProperty ("browser.edge.profile-directory"); edgeOptions.addArguments ("user-data-dir =" + userDataDir); edgeOptions.addArguments ("profile-directory =" + userProfileDir); EdgeDriver driverEdge = new EdgeDriver (edgeOptions);
@lukesoftware this discussion is specific to IEDriverServer, which is used to test Edge in IE Mode. From your sample code, it looks like you are testing Edge in native (Chromium) mode. I've created a separate issue #58. Feel free to continue the discussion there.
Hi, any news on this one? Currently starting Edge in IE mode with the IEDriverServer webdriver doesn't take into account my custom passed path for the user data dir in order to use specific profiles. Any ETA for a fix in the webdriver code?
@cmin764 there's no ETA for a fix in IE Driver. IE Driver maintenance is not a priority for the Edge Developer Tools team due to the fact this is a legacy product and we receive a relatively low volume of feedback about IE Driver usage. The good news is that IE Driver is open source and this specific issue can be fixed entirely in IE Driver. In other words, no MS-internal code should need to be updated which would require our team's expertise. Here's the PR which introduced temporary user data directories to IE Driver as a reference: https://github.com/SeleniumHQ/selenium/pull/10006