Skip to content

Instantly share code, notes, and snippets.

@adiralashiva8
Forked from leeuwe/ReadMe.md
Created July 30, 2023 06:57
Show Gist options
  • Save adiralashiva8/f220ae73d70eb43decbe65a631f86ccd to your computer and use it in GitHub Desktop.
Save adiralashiva8/f220ae73d70eb43decbe65a631f86ccd to your computer and use it in GitHub Desktop.
Base file to speed up your migration from Robot Framework® SeleniumLibrary to Browser

This is a base file to speed up your migration from Robot Framework® SeleniumLibrary to Browser library. The file contains over 40 SeleniumLibrary keywords and may require adjustment to your specific situation.

You should import this resource file INSTEAD of the SeleniumLibrary, NOT in combination with the SeleniumLibrary.

*** Settings ***
Library Browser
*** Keywords ***
Click Element
[Arguments] ${locator}
Click ${locator}
Wait Until Page Contains
[Arguments] ${text} ${timeout}=None ${error}=None
sleep 1s
Wait Until Network Is Idle
Browser.get text css=html contains ${text}
Wait Until Element Is Visible
[Arguments] ${locator} ${timeout}=None ${error}=None
Wait For Elements State ${locator} visible ${timeout} ${error}
Click Button
[Arguments] ${locator}
Click text=${locator}
Wait Until Page Contains Element
[Arguments] ${locator} ${timeout}=0:00:20 ${error}=None ${limit}=None
Wait For Elements State ${locator} attached ${timeout} ${error}
Element Should Be Visible
[Arguments] ${locator} ${message}=None
Wait For Elements State ${locator} visible
Page Should Contain
[Arguments] ${text}
Browser.Get Text //main contains ${text}
Capture Page Screenshot
[Arguments] ${filename}=None
Take Screenshot ${filename}
Wait Until Element Is Not Visible
[Arguments] ${locator} ${timeout}=None ${error}=None
Wait For Elements State ${locator} hidden ${timeout} ${error}
Close All Browsers
Close Context ALL
Click Link
[Arguments] ${locator}
Click ${locator}
Page Should Contain Element
[Arguments] ${locator} ${message}=None
Wait For Elements State ${locator}
Page Should Contain Link
[Arguments] ${url} ${message}=None
${hrefs}= Execute JavaScript Array.from(document.querySelectorAll('a')).map(e => e.getAttribute('href'))
Should Contain ${hrefs} ${url}
Scroll Element Into View
[Arguments] ${locator}
Hover ${locator}
Input Text
[Arguments] ${locator} ${text}
Type Text ${locator} ${text} 50ms
Element Should Contain
[Arguments] ${locator} ${expected} ${Message}=None ${Ignore_case}=None
Browser.Get Text ${locator} contains ${expected}
Wait Until Element Contains
[Arguments] ${locator} ${text} ${timeout}=None ${error}=None
Browser.Get Text ${locator} contains ${text}
Page Should Not Contain Element
[Arguments] ${locator} ${message}=None
Wait For Elements State ${locator} hidden
Page Should Not Contain
[Arguments] ${text}
Browser.Get Text //main validate "${text}" not in value
Page Should Not Contain Link
[Arguments] ${locator} ${message}=None
Wait For Elements State ${locator} hidden
Element Should Not Contain
[Arguments] ${locator} ${text}
Browser.Get Text ${locator} validate "${text}" not in value
Checkbox Should Be Selected
[Arguments] ${locator}
Get Checkbox State ${locator} == CHECKED
Checkbox Should Not Be Selected
[Arguments] ${locator}
Get Checkbox State ${locator} == UNCHECKED
Select Checkbox
[Arguments] ${locator}
Check Checkbox ${locator}
Element Attribute Value Should Be
[Arguments] ${locator} ${attribute} ${expected}
Get Attribute ${locator} ${attribute} == ${expected}
Click Element At Coordinates
[Arguments] ${locator} ${x} ${y}
Click selector=${locator} position_x=${x} position_y=${y}
Mouse Over
[Arguments] ${locator}
Hover ${locator}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment