https://github.com/ascentis/robotframework-seleniumtobrowser
https://github.com/ascentis/robotframework-seleniumtobrowser
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ascentis/robotframework-seleniumtobrowser
- Owner: Ascentis
- License: apache-2.0
- Created: 2021-02-18T14:30:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-25T19:59:22.000Z (about 4 years ago)
- Last Synced: 2025-02-08T14:44:43.788Z (4 months ago)
- Language: Python
- Size: 415 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# robotframework-seleniumtobrowser
[](https://opensource.org/licenses/Apache-2.0)---
## Introduction
Robot Framework SeleniumToBrowser library helps with converting automated tests using [SeleniumLibrary](https://github.com/robotframework/SeleniumLibrary) keywords to [Browser](https://github.com/MarketSquare/robotframework-browser) library
## Usage
A couple of considerations on how to use this library:
- Both Browser and SeleniumToBrowser must be declared inside the robot code.
- "Overlapping keywords" between Selenium and Brower, like Open Browser will need to called with the library prefix## Conversion Guidelines
Browser library provides many keywords that are similar to the ones we have in Selenium, but the correspondence is not one-on-one. There are keywords that can be used to execute the same actions that in Selenium are executed by multiple ones.Here you can access to the documentation of the library: [Browser Library](https://marketsquare.github.io/robotframework-browser/Browser.html.).
### **1. Click Element**
To click on an element with Browser, you use ‘**Click**’. This keyword will replace all the ‘Click Element’, ‘Click Button’, ‘Click Link’ and the rest of ‘click’ keywords we used in Selenium.
This keyword has implicit waits, what means that you don’t need to add ‘waits’ for the element to be visible before clicking. The timeout for the implicit wait is the one set when opening the browser at the beginning, there is no way to pass a custom timeout in this keyword. To don’t use the implicit waits, you can add the argument **force=True**.
The structure is the same, Click + selector of the element.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Click)
|Selenium |Browser |
|---|---|
|**Click Element** selector|**Click** selector|

### **2. Select Option From Dropdown List**
In Selenium, to select an option in a select, we just use ‘Click’. With Browser, there is a specific keyword to do it: ‘Select Options By’. If you use click to select an option in a dropdown list, it doesn’t work.
The structure is: Select Options By + selector + attribute + value.
The attribute is the way you will use to select the element, could be value, label, text or index.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Select%20Options%20By)
|Selenium |Browser |
|---|---|
|**Click Element** select_locator|**Select Options By** select_locator attribute option_value
|**Click Element** option_locator||

### **3. Select Checkbox**
Instead of using ‘Select checkbox’ as we do in Selenium, in Browser we need to use ‘Check Checkbox’ to select a checkbox.
The syntax is: Check Checkbox + selector.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Check%20Checkbox)

|Selenium |Browser |
|---|---|
|**Select Checkbox** selector|**Check Checkbox** selector|
**Note:** This will fail if the checkbox is already checked. In that case you can first use ‘Get Checkbox State’ to know if the checkbox is already checked.

### **4. Unselect Checkbox**
Is the opposite to the previous keyboard. You can use ‘Uncheck Checkbox’ to uncheck a checkbox.
The syntax is: Uncheck Checkbox + selector.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Uncheck%20Checkbox)

|Selenium |Browser |
|---|---|
|**Unselect Checkbox** selector|**Uncheck Checkbox** selector|
### **5. Input Text**
To migrate from Selenium to Browser, you need to replace all the ‘Input Text’ with ‘Fill Text’. The syntax is the same and the behavior too. It will add the sent text to the field all at once. If you need to input the text simulating typing you can use ‘Type Text’.
Syntax: Fill text + selector + text
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Fill%20Text)

|Selenium |Browser |
|---|---|
|**Input Text** selector text|**Fill Text** selector text|
### **6. Press Keys**
The keyword has the same name as browser one. In this case you don’t need to replace anything, it will work as it was before.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Press%20Keys)
### **7. Mouse Over**
The keyword ‘Hover’ will replace the ‘Mouse Over’ keyword from Selenium library. The syntax is the same, you just need to pass the locator for the element.
Syntax: Hover + locator
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Hover)

|Selenium |Browser |
|---|---|
|**Mouse Over** selector|**Hover** selector|
### **8. Scroll To Element**
As you know, we usually use javascript to scroll to an element. Browser provides a keyword called ‘Scroll To’ but in reality, you won’t need to use it in most of the cases. Browser does it implicity when using ‘Click’ for example.
### **9. Wait Until Element Is Visible**
In Browser we have ‘Wait For Elements State’. This keyword can replace multiple keywords from Selenium. It accepts arguments, so you can check for the state you need: attached, detached, visible, hidden, enabled, disabled, etc. Here you can see all the accepted attributes: [Element States](https://marketsquare.github.io/robotframework-browser/Browser.html#ElementState)
By default, the attribute that is verified is ‘visible’. So when you use: ‘Wait For Elements State + selector’ without adding the explicit attribute, the test will wait until the element is visible. This will replace then ‘Wait Until Element Is Visible’.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Wait%20For%20Elements%20State)

|Selenium |Browser |
|---|---|
|**Wait Until Element Is Visible** selector|**Wait For Elements State** selector|
### **10. Wait Until Element Is Not Visible**
View 9. for description.
|Selenium |Browser |
|---|---|
|**Wait Until Element Is Not Visible** selector|**Wait For Elements State** selector hidden|
### **11. Wait Until Element Is Enabled**
View 9. for description.
|Selenium |Browser |
|---|---|
|**Wait Until Element Is Enabled** selector|**Wait For Elements State** selector enabled|
### **12. Wait Until Page Contains Element**
View 9. for description.
|Selenium |Browser |
|---|---|
|**Wait Until Page Contains Element** selector|**Wait For Elements State** selector attached|
### **13. Wait Until Page Does Not Contain Element**
View 9. for description.
|Selenium |Browser |
|---|---|
|**Wait Until Page Does Not Contain Element** selector|**Wait For Elements State** selector detached|
### **14. Element Should Be Visible**
In Browser we use ‘Get Element State’ to verify the status of an element. This keyword is useful to verified that an element has the expected state. You can verify from multiple attributes, like in the previous keyword ([Element States](https://marketsquare.github.io/robotframework-browser/Browser.html#ElementStateKey)) and the default one is ‘visible’. In the practice it will replace all the ‘Element Should Be’ keywords.
By default, this keyword verified that the attribute you pass is true. It returns true or false depending on the result.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Get%20Element%20State)
|Selenium |Browser |
|---|---|
|**Element Should Be Visible** selector|**Get Element State** selector|
### **15. Element Should Not Be Visible**
View 14. for description.

|Selenium |Browser |
|---|---|
|**Element Should Not Be Visible** selector|**Get Element State** selector visible == False|
### **16. Element Should Not Be Visible**
View 14. for description.
|Selenium |Browser |
|---|---|
|**Element Should Be Enabled** selector|**Get Element State** selector disabled == False|
### **17. Element Should Be Disabled**
View 14. for description.
|Selenium |Browser |
|---|---|
|**Element Should Be Disabled** selector|**Get Element State** selector disabled|
### **18. Element Should Be Focused**
View 14. for description.
|Selenium |Browser |
|---|---|
|**Element Should Be Focused** selector|**Get Element State** selector focused|
### **19. Page Should Contain Element**
View 14. for description.
|Selenium |Browser |
|---|---|
|**Page Should Contain Element** selector|**Get Element State** selector attached|
### **20. Page Should Not Contain Element**
View 14. for description.
|Selenium |Browser |
|---|---|
|**Page Should Not Contain Element** selector|**Get Element State** selector attached == False|
### **21. Checkbox Should Be Selected**
In Browser we use ‘Get Checkbox State’. It’s similar to the previous one, but specific to get the state of the checkboxes. It would replace the following keywords from Selenium. By default, the keyword will check and return true if the checkbox is unchecked.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Get%20Checkbox%20State)

|Selenium |Browser |
|---|---|
|**Checkbox Should Be Selected** selector|**Get Checkbox State** selector|
### **22. Checkbox Should Be Selected**
In Browser we use ‘Get Checkbox State’. It’s similar to the previous one, but specific to get the state of the checkboxes. It would replace the following keywords from Selenium. By default, the keyword will check and return true if the checkbox is unchecked.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Get%20Checkbox%20State)

|Selenium |Browser |
|---|---|
|**Checkbox Should Be Selected** selector|**Get Checkbox State** selector|
### **23. Checkbox Should Not Be Selected**
In Browser we use ‘Get Checkbox State’. It’s similar to the previous one, but specific to get the state of the checkboxes. It would replace the following keywords from Selenium. By default, the keyword will check and return true if the checkbox is unchecked.
[Keyword Documentation](https://marketsquare.github.io/robotframework-browser/Browser.html#Get%20Checkbox%20State)
|Selenium |Browser |
|---|---|
|**Checkbox Should Not Be Selected** selector|**Get Checkbox State** selector|
### **24. Select Frame**
Another thing to take into account when migrating to Browser, is that here we don’t have a ‘Select Frame’ keyword to search elements inside them. The way you interact with elements inside a frame, is by passing the frame locator and then the element.
For example if you want to click an element inside a frame, you should use:
Syntax: Click frame_locator >>> element_locator

|Selenium |Browser |
|---|---|
|**Select Frame** frame_locator|**Click** frame_locator >>> element_inside_frame|
|**Click Element** element_inside_selected_frame||