Robot Framework: - 无法从现有的Chrome个人资料中打开Chrome [英] Robot Framework :- Cannot Open Chrome from Existing Chrome Profile

查看:451
本文介绍了Robot Framework: - 无法从现有的Chrome个人资料中打开Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图学习机器人框架。我已经在Selenium Webdriver上工作过。我试图使用创建Webdriver关键字从一个退出配置文件打开Chrome浏览器。但是我无法做到。看起来,Robot Framework每次都会打开一个新的Chrome Profile。
以下是我使用goggling后得到的代码,但这并不是从我喜欢的用户数据文件夹中打开Chrome。任何建议或意见,这可以实现。

 使用创建WebDriver关键字打开Chrome关键字
[标签] chrome
$ {options} =评估sys.modules ['selenium.webdriver']。ChromeOptions()sys,selenium.webdriver $ b $ {options.add_argument} =设置变量 - 允许运行不安全内容
$ {options.add_argument} =设置变量--disable-web-security
$ {options.add_argument} =设置变量user-data-dir = / Users / myName / AppData / Local / Google / Chrome /用户数据
创建WebDriver Chrome chrome_options = $ {options}
转到{URL}

#关闭浏览器

解决方案

要添加参数,请调用 add_argument > ChromeOptions 对象。请注意,您需要在--user-data-dir参数中转义'=',否则Robot Framework将查找名为'--user-data-dir'的参数并失败。当测试这个时,我注意到一个配置文件将在指定的位置创建,如果它不存在。

 使用Create WebDriver关键字
$ {options} =评估sys.modules ['selenium.webdriver']。ChromeOptions()sys,selenium.webdriver
调用方法$ {options} add_argument --allow-running-insecure-content
调用方法$ {options} add_argument --disable-web-security
调用方法$ {options} add_argument --user-data-dir\ = / Users / myName / AppData / Local / Google / Chrome /用户数据
创建WebDriver Chrome chrome_options = $ {options}
转至https://stackoverflow.com


I am trying to Learn Robot Framework. I have already worked on Selenium Webdriver. I was trying to open the Chrome Browser from an Exiting Profile using Create Webdriver Keyword. However i am not able to do . It Seems that Robot Framework Opens a new Chrome Profile Everytime. Here is the Code that i got after goggling, but this is not opening Chrome from the User data folder that i prefer. Any Suggestions or Ideas this can be achieved.

    Open Chrome Using Create WebDriver Keyword
[Tags]  chrome
${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
${options.add_argument}=  Set Variable  --allow-running-insecure-content
${options.add_argument}=  Set Variable  --disable-web-security
${options.add_argument}=  Set Variable  user-data-dir = /Users/myName/AppData/Local/Google/Chrome/User Data
Create WebDriver  Chrome  chrome_options=${options}
go to  {URL}

# Close Browser

解决方案

To add arguments, call the add_argument method of the ChromeOptions object. Note that you need to escape the '=' in the --user-data-dir argument or Robot Framework will look for an argument called '--user-data-dir' and fail. When testing this I noticed that a profile will be created in the location specified if it does not exist.

Open Chrome Using Create WebDriver Keyword
    ${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${options}    add_argument    --allow-running-insecure-content
    Call Method    ${options}    add_argument    --disable-web-security
    Call Method    ${options}    add_argument    --user-data-dir\=/Users/myName/AppData/Local/Google/Chrome/User Data
    Create WebDriver    Chrome    chrome_options=${options}
    Go To    https://stackoverflow.com

这篇关于Robot Framework: - 无法从现有的Chrome个人资料中打开Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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