每当我运行自动化测试脚本时,Chrome扩展程序就会消失 [英] Chrome extension disappear every time i run my automation test script
问题描述
我需要使用Selenium Robot Framework
测试Chrome扩展程序吗?
I need to test Chrome extension using Selenium Robot Framework
?
扩展程序已安装在浏览器中,但是每次我运行测试脚本时它都会消失.
Extension is installed on the browser, but it disappears every time I run my test script.
任何人都可以告诉我在Selenium Robot Framework
Can anyone tell me the steps I need to follow in Selenium Robot Framework
推荐答案
有两种方法.您可以指示Chrome在启动时安装特定的扩展程序,也可以使用安装了扩展程序的永久配置文件.要获取扩展名的crx文件,请参见给我CRX .请参阅此帮助主题,以创建可在其中安装扩展程序的新配置文件. >
There are two approaches to this. You can instruct Chrome to install a specific extension on startup or you can use a persistent profile where an extension is installed. To get a crx file for an extension, see Give Me CRX. See this help topic on creating a new profile into which you can install an extension.
*** Settings ***
Test Teardown Close All Browsers
Library Selenium2Library
*** Test Cases ***
Install Extension On Startup
${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome options} add_extension C:\\ws\\extension_2_0_2.crx
Create Webdriver Chrome chrome_options=${chrome options}
Goto https://stackoverflow.com
Sleep 1 minute # manually verify the extension is active
Using Saved Profile
${chrome options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${chrome options} add_argument user-data-dir\=C:\\ws\\User Data
Create Webdriver Chrome chrome_options=${chrome options}
Goto https://stackoverflow.com
Sleep 1 minute # manually verify the extension is active
user-data-dir后的'\'用来转义'=',因此Robot Framework不会将user-data-dir解释为关键字参数名称.
The '\' after user-data-dir is to escape the '=' so Robot Framework does not interpret user-data-dir as a keyword argument name.
这篇关于每当我运行自动化测试脚本时,Chrome扩展程序就会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!