Hello everybody,
I’m new to Robot Framework and Keyword based programming.
I got the Following Code files:
Test.robot
Summary
*** Settings ***
Documentation RobotFramework-testen
Metadata Author Tobias Marx
Metadata Version 1.1
Force Tags IPRL-Testing
Suite Setup Open Browser \ ${BROWSER}
Suite Teardown Close Browser
Library SeleniumLibrary
Library OperatingSystem
Resource …/Resources/locators.resource
Resource …/Resources/methods.resource
*** Keywords ***
*** Variables ***
${Umgebung} *****
${URL} *****
${BROWSER} chrome
${USERNAME} *****
${PASSWORD} *****
${OUTPUT_DIR} /log/
*** Test Cases ***
Test
Navigate and Login ${URL} ${USERNAME_TEXTAREA} ${USERNAME} ${PASSWORD_TEXTAREA} ${PASSWORD} ${ANMELDEN_BUTTON}
Einfach Weiter
Click Element ${AKTUELLE_AUSSCHR_LINK}
Sleep 1
Click Element ${AUSSCHR_VERW_LINK}
Sleep 1
Click Element ${PRODUKTART_DROPDOWN}
Sleep 1
Click Element ${PRODUKTART_DD_SRL}
Sleep 2
Search Open Run
Sleep 5
Methods.resource
Summary
*** Settings ***
Library OperatingSystem
Library SeleniumLibrary
Library Collections
Library CustomLibrary.py
*** Keywords ***
Search Open Run
Find And Click Link
CustomLibrary.py
Summary
from SeleniumLibrary import SeleniumLibrary
from SeleniumLibrary.base import keyword, LibraryComponent
from SeleniumLibrary.keywords import BrowserManagementKeywords
from robot.libraries.BuiltIn import BuiltIn
from selenium.webdriver.common.by import By
def find_and_click_link():
flag = False
link = None
seleniumlib = BuiltIn().get_library_instance(“SeleniumLibrary”)
# Find the table
table = seleniumlib.find_element(By.TAG_NAME, "table")
# Get all rows in the table
rows = table.find_elements(By.TAG_NAME, "tr")
for row in rows:
# Get the cells in each row
cells = row.find_elements(By.TAG_NAME, "td")
# Iterate over the cells
for cell in cells:
if flag:
cell.find_element(By.TAG_NAME, "a").click()
break
elif cell.text == "Warte auf Vergabevorschlag":
flag = True
if flag:
flag = False
break
My Problem is, i need to pass the browser Instance i started in the Test.robot file to my CustomLibrary.py
But i always get errors like this:
ValueError: Parent must be Selenium WebElement but it was <class ‘str’>.