Best Python code snippet using SeleniumBase
test_tweet.py
Source:test_tweet.py
...69 @parameterized.expand(timeline)70 def test_timeline(self, index, fullname, username, date, tid, text):71 self.open_nitter(username)72 tweet = get_timeline_tweet(index)73 self.assert_exact_text(fullname, tweet.fullname)74 self.assert_exact_text('@' + username, tweet.username)75 self.assert_exact_text(date, tweet.date)76 self.assert_text(text, tweet.text)77 permalink = self.find_element(tweet.date + ' a')78 self.assertIn(tid, permalink.get_attribute('href'))79 @parameterized.expand(status)80 def test_status(self, tid, fullname, username, date, text):81 tweet = Tweet()82 self.open_nitter(f'{username}/status/{tid}')83 self.assert_exact_text(fullname, tweet.fullname)84 self.assert_exact_text('@' + username, tweet.username)85 self.assert_exact_text(date, tweet.date)86 self.assert_text(text, tweet.text)87 @parameterized.expand(multiline)88 def test_multiline_formatting(self, tid, username, text):89 self.open_nitter(f'{username}/status/{tid}')90 self.assert_text(text.strip('\n'), '.main-tweet')91 @parameterized.expand(emoji)92 def test_emoji(self, tweet, text):93 self.open_nitter(tweet)94 self.assert_text(text, '.main-tweet')95 @parameterized.expand(link)96 def test_link(self, tweet, links):97 self.open_nitter(tweet)98 for link in links:99 self.assert_text(link, '.main-tweet')100 @parameterized.expand(username)101 def test_username(self, tweet, usernames):102 self.open_nitter(tweet)103 for un in usernames:104 link = self.find_link_text(f'@{un}')105 self.assertIn(f'/{un}', link.get_property('href'))106 @parameterized.expand(retweet)107 def test_retweet(self, index, url, retweet_by, fullname, username, text):108 self.open_nitter(url)109 tweet = get_timeline_tweet(index)110 self.assert_text(f'{retweet_by} retweeted', tweet.retweet)111 self.assert_text(text, tweet.text)112 self.assert_exact_text(fullname, tweet.fullname)113 self.assert_exact_text(username, tweet.username)114 @parameterized.expand(invalid)115 def test_invalid_id(self, tweet):116 self.open_nitter(tweet)117 self.assert_text('Tweet not found', '.error-panel')118 @parameterized.expand(reply)119 def test_thread(self, tweet, num):120 self.open_nitter(tweet)121 thread = self.find_element(f'.timeline > div:nth-child({num})')...
sbaseTest.py
Source:sbaseTest.py
...17 # Verify the cart18 self.click("#shopping_cart_container")19 self.assert_element('span:contains("Your Cart")')20 self.assert_text(item_name, "div.inventory_item_name")21 self.assert_exact_text("1", "div.cart_quantity")22 self.assert_exact_text("REMOVE", "button.cart_button")23 self.assert_element("button#continue-shopping")24 # Checkout and adding informattion25 self.click('button[name="checkout"]')26 self.type('input[name="firstName"]', "standard")27 self.type('input[name="lastName"]', "user")28 self.type('input[name="postalCode"]', "02130")29 # Verify checkout30 self.click("input#continue")31 self.assert_element('span:contains("Checkout: Overview")')32 self.assert_element("button#cancel")33 self.assert_text(item_name, "div.inventory_item_name")34 self.assert_text(item_price, "div.inventory_item_price")35 self.assert_exact_text("1", "div.cart_quantity")36 # Finish Checkout37 self.click('button[name="finish"]')38 self.assert_text('THANK YOU FOR YOUR ORDER')39 # locked_out_user40 def test_lockedUser(self):41 ## Login to Swag Labs with locked_out_user Credentials42 self.open("https://www.saucedemo.com/")43 self.type('input[name="user-name"]', "locked_out_user")44 self.type('input[name="password"]', "secret_sauce")45 self.click('input[name="login-button"]')46 47 ## Verify that the error comes out while login 48 self.assert_text('Epic sadface: Sorry, this user has been locked out.')49 # problem_user50 def test_problemUser(self):51 ## Login to Swag Labs with problem_user Credentials 52 self.open("https://www.saucedemo.com/")53 self.type('input[name="user-name"]', "problem_user")54 self.type('input[name="password"]', "secret_sauce")55 self.click('input[name="login-button"]')56 57 # Verify that the "Sauce Labs Backpack" appears on the page58 item_name = "Sauce Labs Backpack"59 self.assert_text(item_name)60 item_price = self.get_text("div.inventory_item_price")61 ## add to card the Sauce Labs Backpack62 self.click('button[name="add-to-cart-sauce-labs-backpack"]')63 # Verify the cart64 self.click("#shopping_cart_container")65 self.assert_element('span:contains("Your Cart")')66 self.assert_text(item_name, "div.inventory_item_name")67 self.assert_exact_text("1", "div.cart_quantity")68 self.assert_exact_text("REMOVE", "button.cart_button")69 self.assert_element("button#continue-shopping")70 # Checkout and adding informattion71 self.click('button[name="checkout"]')72 self.type('input[name="firstName"]', "problem")73 self.type('input[name="lastName"]', "user")74 self.type('input[name="postalCode"]', "02130")75 # Verify the problem with the page76 self.click('input[name="continue"]')77 self.assert_text('Error: Last Name is required')...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!