1
votes

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

1
What does "not working" mean? Do you get any errors? Does it open the wrong browser? Does robot crash? - Bryan Oakley
I was able to launch my app with ... ${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver Create WebDriver Chrome my_alias chrome_options=${options} executable_path=C:/Program Files (x86)/InTouch Health/Carestation/Carestation.exe But, I'm unable to use that webdriver instance with other calls like close Browser. How can I make a unique webdrive(link to an app) and have my selenium/robot calls directed to it. Is there a way to pass this object to the other calls or make it a global object? - lkneafsey
Note with python/ selenium I use 'driver' in the example above. - lkneafsey
please don't put code in the comment section, it's impossible to read. If you need to add more information to your question, you can edit your question. And you haven't answered my first question, which is "what does 'not working' mean? - Bryan Oakley
By not working - it was always launching the Chrome Browser not my Chomium application. I want to launch a chromium application. I was now able to do this but now I can't seem to use the Chomium app object with the rest of the robot/selenium2library calls. How can this work? - lkneafsey

1 Answers

-1
votes

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}