How to use go_to_google method in SeleniumBase

Best Python code snippet using SeleniumBase

test_page_objects.py

Source:test_page_objects.py Github

copy

Full Screen

1""" Example test that uses the Page Object Model """2from seleniumbase import BaseCase3class GooglePage:4 def go_to_google(self, sb):5 sb.open("https://google.com/ncr")6 def do_search(self, sb, search_term):7 sb.type('input[title="Search"]', search_term + "\n")8 def click_search_result(self, sb, content):9 sb.click('a[href*="%s"]' % content)10class SeleniumBaseGitHubPage:11 def click_seleniumbase_io_link(self, sb):12 link = '#readme article a[href*="seleniumbase.io"]'13 sb.wait_for_element_visible(link)14 sb.js_click(link)15 sb.switch_to_newest_window()16class SeleniumBaseIOPage:17 def do_search_and_click(self, sb, search_term):18 if sb.is_element_visible('[for="__search"] svg'):19 sb.click('[for="__search"] svg')20 sb.type('form[name="search"] input', search_term)21 sb.click("li.md-search-result__item h1:contains(%s)" % search_term)22class MyTests(BaseCase):23 def test_page_objects(self):24 search_term = "SeleniumBase GitHub"25 expected_text = "seleniumbase/SeleniumBase"26 GooglePage().go_to_google(self)27 GooglePage().do_search(self, search_term)28 self.assert_text(expected_text, "#search")29 GooglePage().click_search_result(self, expected_text)30 SeleniumBaseGitHubPage().click_seleniumbase_io_link(self)31 SeleniumBaseIOPage().do_search_and_click(self, "Dashboard")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful