简体   繁体   中英

How to open a Chrome application into Robot using selenium2Library

I'm trying to open our windows Chrome exe in Robot using selenium2Library. I've tried creating a webdriver using Create Webdriver with this code but it's not working.

${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()       sys, selenium.webdriver.chrome.options
${options.add_extension}=        Set_Variable          path/to/extension
Create WebDriver    Chrome    chrome_options=${options}

In Python I do this... and it launches my app in selenium.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.action_chains import ActionChains

def chromedr():
    chrome_options = Options()
    chrome_options.binary_location = 'C:/Program Files (x86)/InTouch Health/Carestation/Carestation.exe'
    driver = webdriver.Chrome('C:/Program Files (x86)/InTouch Health/Carestation/chromedriver.exe', chrome_options=chrome_options)  
    return driver

How can I do this in Robot/selenium2Library?

I was able to launch the Application using this code: ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver Create WebDriver Chrome my_alias chrome_options=${options} executable_path=C:/Program Files (x86)/Myapp.exe

To open chrome with robotframework selenium2library

1) install selenium2Library through pip

2) download and extract Chrome driver exe, add it to environment variables

3) you can invoke chrome like below

*** Settings ***
Library    Selenium2Library
*** Variables ***
${SiteUrl}    https://stackoverflow.com
${Browser}    Chrome
*** Test Cases ***
Test
    Open Browser and login
*** Keywords ***
Open Browser and login
    open browser    ${SiteUrl}    ${Browser} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM