使用Watir-Webdriver时Chrome中的默认配置文件名称? [英] Default profile name in Chrome when using Watir-Webdriver?

查看:187
本文介绍了使用Watir-Webdriver时Chrome中的默认配置文件名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了Chromedriver,然后将其提取到正确的位置(usr / bin),但我不知道Chrome(Chromium)浏览器的默认配置文件名是什么,因此此行会引发错误消息:

  browser = Watir :: Browser.new:chrome,:profile => 默认

我尝试了当前或我的用户名而不是默认,但没有他们工作。我如何使用我的默认配置文件启动Chrome?因为我不想在没有通常的偏好的情况下开始一个新的个人资料,并且保存密码,cookies等。

可以在 chrome:// version / url

处看到默认路径

在我的例子中,它是 / Users / mikhail / Library / Application Support / Google / Chrome / Default



由于某些原因, '/ Default'路径部分:

  require'watir-webdriver'

username =' mikhail'
switches =%W [ - user-data-dir = / Users /#{username} / Library / Application\ Support / Google / Chrome /]

browser = Watir :: Browser.new:chrome,开关:开关
browser.goto'google.com'


I downloaded the Chromedriver then I extracted it to the right place (usr/bin), but I don't know what is the default profile name for the Chrome (Chromium) browser, so this line throw an error message:

browser = Watir::Browser.new :chrome, :profile => "default"

I tried either "current" or my username instead of "default", but none of them worked. How can I start Chrome with my default profile? Because I don't want to start a new profile without the usual preferences, and saved passwords, cookies, etc.

解决方案

You can see you default path at chrome://version/ url

In my case it is /Users/mikhail/Library/Application Support/Google/Chrome/Default

For some reason proper path would be this string without last '/Default' part of the path:

require 'watir-webdriver'

username = 'mikhail'
switches = %W[--user-data-dir=/Users/#{username}/Library/Application\ Support/Google/Chrome/]

browser = Watir::Browser.new :chrome, switches: switches
browser.goto 'google.com'

这篇关于使用Watir-Webdriver时Chrome中的默认配置文件名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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