Selenium Grid 2-Chromedriver不会在新运行中启动新的配置文件 [英] Selenium Grid 2 - Chromedriver does not start a new profile on a new run

查看:186
本文介绍了Selenium Grid 2-Chromedriver不会在新运行中启动新的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用selenium webdriver(chromedriver)和rubyselenium grid 2在Chrome上测试网站时,我手动单击了Allow来跟踪我的位置.

While testing a website on Chrome using selenium webdriver (chromedriver) with ruby and selenium grid 2, I manually clicked on Allow to track my location.

从那时起,每次新运行都会由Chrome浏览器跟踪我的位置并且不再请求权限.

Since then every new run starts off with the Chrome browser tracking my location and not asking for permission anymore.

根据我的理解,这不会发生,因为Selenium应该创建一个新的配置文件,并且不记得上一次运行中的任何用户交互.

In my understanding that should not happen, as Selenium should create a new profile and not remember any user interactions in the previous run.

我还尝试过以管理员身份手动打开Chrome浏览器,并更改设置以忘记要测试的网站的位置服务设置的任何权限.但这也没有帮助.

I have also tried to open the Chrome Browser as an admin (manually) and change the settings to forget any permissions set for location services for the site being tested. But that has not helped either.

我也尝试过重新启动网格,但这也无济于事.

I have also tried to restart the grid but that has not helped either.

有人知道我如何使浏览器忘记我的许可吗?

Does anyone know how do I make the browser forget my permission?

更新

启动驱动程序的代码

@driver = Selenium::WebDriver.for(:remote, :url => @sel_grid_url, :desired_capabilities => @browser)

推荐答案

尝试一下.

profile = Selenium::WebDriver::Chrome::Profile.new

data = profile.as_json

caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps['chromeOptions'] = {
  'profile'    => data['zip'],
  'extensions' => data['extensions']
}

driver = Selenium::WebDriver.for(:remote, :url => @sel_grid_url, :desired_capabilities => caps)

还要验证是否已选中Settings -> Advanced Settings -> Privacy -> Content Settings -> Location下的Ask me when a site tries to track my physical location (recommended)选项.

Also verify that you have Ask me when a site tries to track my physical location (recommended) option checked, under Settings -> Advanced Settings -> Privacy -> Content Settings -> Location.

更新:

另一种尝试.

profile = Selenium::WebDriver::Chrome::Profile.new
profile['download.prompt_for_download'] = false
profile['download.default_directory'] = "/path/to/dir"
profile['profile.managed_default_content_settings.geolocation'] = 2 #Try 1 and 0 as well


data = profile.as_json

caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps['chromeOptions'] = {
  'profile'    => data['zip'],
  'extensions' => data['extensions']
}

driver = Selenium::WebDriver.for(:remote, :url => @sel_grid_url, :desired_capabilities => caps)

这篇关于Selenium Grid 2-Chromedriver不会在新运行中启动新的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆