SeleniumBase framework comes with a set of pre-defined APIs or helper methods for us to use. In this post, we will get familiar with some of the common SeleniumBase API such as click, get_text, assert_text, etc… and understand how it works and which ones to use when.
? Why use SeleniumBase API?
SeleniumBase API provides us with helper wrapper methods to use that are built on top of regular selenium commands. These wrapper methods make working with Selenium a lot easier as it comes with in-built smart wait features to make your tests more reliable. So, you do not have to worry about adding waits or sleeps after every other command, as all of that gets dealt with by SeleniumBase APIs.
You can also take advantage of the SeleniumBase helper methods to write your tests quickly and effectively.
Scenario #1 – Click on a button and assert url
# click on the get started button and assert the url self.click("#get-started") # get the current url of the page get_started_url = self.get_current_url() # assertion option 1 self.assert_equal(get_started_url, "https://practice.automationbro.com/#get-started") # assertion option 2 self.assert_true("get-started" in get_started_url)
Scenario #2 – Scroll and assert the text of the element
# scroll to the bottom of the screen and assert the text self.scroll_to_bottom() # assert the text of the element provided self.assert_text("Copyright © 2020 Automation Bro", ".tg-site-footer-section-1")
Check out the video below to learn more about the SeleniumBase APIs –
I hope this post helped you out, let me know if you have any questions in the comments below!
Happy testing!