I have created a python code to initialise a chrome browser and I want to pass this driver instance to Robot Framework so that the keywords of RF will work on this instance. Please let me know how could i do the same. The Py code for intializing a file is :
'class SeleniumKeywords:
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
def __init__(self):
self.driver = None
def open_browser(self, browser="chrome"):
driver_class = drivers[browser]
self.driver = driver_class()
def go_to(self, url):
self.driver.get(url)'
Now when using it in Robot framework, the browser opens but the RF keywords doesnt work on it(selenium2library keywords). Basically I opening an browser instance using the custom keyword and maximizing using selenium2library keywords in RF. Unfortunately it doesnt work. Please let me know how to pass this browser instance to RF:
'*** Settings ***
Library ExtendedSelenium2Library
Library ../Resources/SeleniumKeywords.py
Resource ../Global/GlobalConfig.robot
*** Test Cases ***
Reuse Session ID
SeleniumKeywords.Open Browser chrome
maximize browser window
SeleniumKeywords.Go To ${URL} '
The maximize browser window is a RF keyword and I want it to work on my browserinstance
ExtendedSelenium2Library
? Why not have your code use the one opened byExtendedSelenium2Library
instead of the other way around? – Bryan OakleyMaximize Browser Window
: it doesn't always work as advertised, especially on Chrome. Also, I can shorten your test case:Open Browser ${URL} chrome
,Maximize Browser Window
. ProvidedMaximize Browser Window
works for your setup, that will do exactly what you seem to be trying to do. You don't need to specifically call SeleniumKeywords, you already initialized those exact keywords in your instance with yourLibrary ExtendedSelenium2Library
call. – Brandon Olson