Selenium-Remote-Driver icon indicating copy to clipboard operation
Selenium-Remote-Driver copied to clipboard

How can I pass capabilities to Selenium::Edge?

Open nck974 opened this issue 4 years ago • 3 comments

Hello, thx for the implementation of #463 so quickly. Now I'm trying with the new veersion, but I'm not able to see how to forward settings to my edge driver. I have tried something as follows:

my $settings_ref = {
		binary =>'msedgedriver.exe',
		extra_capabilities =>
			{'ms:edgeOptions' => {
                            'debuggerAddress' => 'localhost:50923'
			}
		},
	};

Similar to what I do in chrome, but id does not seem to work, as dumping what get_capabilities returns states:

          'ms:edgeOptions' => {
                                'debuggerAddress' => 'localhost:51551'
                              },

This is what I'm trying to migrate to edge from chrome, but I'm not able to get it started:

	if (defined($args_ref->{'downloads_folder'})){
		$settings{'extra_capabilities'}{'goog:chromeOptions'}{'prefs'}{'download.default_directory'} = $args_ref->{'downloads_folder'};
		$settings{'extra_capabilities'}{'goog:chromeOptions'}{'prefs'}{'download.prompt_for_download'} = 'false';
		$settings{'extra_capabilities'}{'goog:chromeOptions'}{'prefs'}{'profile'}{'default_content_setting_values'}{'automatic_downloads'} = 1;
	}

nck974 avatar Mar 09 '21 11:03 nck974

Gave it a spin, and am encountering similar difficulties.

https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options

Seems to suggest valid keys for the 'prefs' object is described in a config file "in the user data folder for microsoft edge". Unfortunately I couldn't find anything of the sort for edge in %APPDATA% or %LOCALAPPDATA%, so I'm not real sure if there are differences versus chrome.

It could also just be their driver doesn't return that as part of the capabilities, though I regard that as unlikely.

teodesian avatar Mar 09 '21 15:03 teodesian

Is it possible that some line like this one is needed in the driver.pm ?:

    #Fix broken out of the box chrome because they hate the maintainers of their interfaces
    if ( $self->isa('Selenium::Chrome') ) {
        if ( exists $args->{desiredCapabilities} ) {
            $args->{desiredCapabilities}{'goog:chromeOptions'}{args} //= [];
            push(@{$args->{desiredCapabilities}{'goog:chromeOptions'}{args}}, qw{no-sandbox disable-dev-shm-usage});
        }
    }

in https://github.com/teodesian/Selenium-Remote-Driver/blob/master/lib/Selenium/Remote/Driver.pm#L1057

nck974 avatar Mar 09 '21 16:03 nck974

possibly. Looking at that block I should also probably filter args[] thru List::Util::uniq.

teodesian avatar Mar 09 '21 17:03 teodesian