Search code examples
pythonseleniumrobotframeworkopera

Using Opera with Robotframework on Windows


I am facing with trouble to use Opera for web site testing in Robotframework with SeleniumLibrary. I figured out because the code does not handle correctly the Windows path. (Default approach on Windows: using \ in path instead of /)

To prove this I was able to manage Opera from python if I replace "\" to "/".

See following code:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.binary_location = "c:/test2/opera.exe"# path to opera executable
driver = webdriver.Opera(options=options)
driver.get("http://www.opera.com")# success

I try to achive the same within Robotframework with "Create Webdriver" key

See following code:

*** Settings ***
Library             Selenium2Library

*** Test Cases ***
Verify Opera
    ${options}=     Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()       sys
    ${options.binary_location}=     Set Variable    C:/Program Files/Opera/51.0.2830.40/opera.exe
    Create Webdriver    Opera   options=${options}

But this approach return with the following error message:

TypeError: __init__() got an unexpected keyword argument 'options'

Could someone help me, what I miss?


Solution

  • Try to execute the robot script with Python 3.x