How to use select_single_item method in lettuce_webdriver

Best Python code snippet using lettuce_webdriver_python

base.py

Source:base.py Github

copy

Full Screen

...21 self.accept_next_alert = True22 def _create_user(self, user, user_data):23 self.driver.get(var.home_page)24 self.driver.find_element_by_css_selector('a.btn.sign-up').click()25 self.select_single_item('id_username', user_data['id_username'])26 self.set_text_id('id_profile_colour', user_data['id_profile_colour'])27 self.select_single_item('id_security_question_1', user_data['id_security_question_1'])28 self.set_text_id('id_security_answer_1', user_data['id_security_answer_1'])29 self.select_single_item('id_security_question_2', user_data['id_security_question_2'])30 self.set_text_id('id_security_answer_2', user_data['id_security_answer_2'])31 self.set_text_id('id_password1', user_data['id_password1'])32 self.set_text_id('id_password2', user_data['id_password2'])33 self.driver.find_element_by_css_selector('div.form-footer > input.btn-submit').click()34 # Login with correct data35 def login(self, user):36 self.driver.get(var.home_page)37 self.set_text_id('id_user-username', user.username)38 self.set_text_id('id_user-password', user.password)39 self.driver.find_element_by_css_selector('input.btn-submit').click()40 # Check if login was succesful by getting username41 self.find_text_element('Log out of JoopeA')42 def admin_login(self, username, password):43 self.driver.get(var.admin_page)44 self.set_text('id_username', username)45 self.set_text('id_password', password)46 self.driver.find_element_by_css_selector('input.grp-button.grp-default').click()47 def set_text_id(self, field_id, text):48 self.driver.find_element_by_id(field_id).clear()49 self.driver.find_element_by_id(field_id).send_keys(text)50 def set_text_name(self, field_name, text):51 self.driver.find_element_by_name(field_name).clear()52 self.driver.find_element_by_name(field_name).send_keys(text)53 def set_text_selector(self, selector, text):54 self.driver.find_element_by_css_selector(selector).clear()55 self.driver.find_element_by_css_selector(selector).send_keys(text)56 def find_css_element(self, selector_id):57 try:58 self.assertTrue(self.is_element_present(By.CSS_SELECTOR, selector_id))59 except AssertionError as e:60 self.verificationErrors.append(str(e))61 def find_text_element(self, text):62 try:63 self.assertTrue(self.is_element_present(By.LINK_TEXT, text))64 except AssertionError as e:65 self.verificationErrors.append(str(e))66 def assert_text_with_xpath(self, value, find_xpath):67 try:68 self.assertEqual(value, self.driver.find_element_by_xpath(find_xpath).text)69 except AssertionError as e:70 self.verificationErrors.append(str(e))71 def assert_text_with_selector(self, text, selector_id):72 try:73 self.assertEqual(text, self.driver.find_element_by_css_selector(selector_id).text)74 except AssertionError as e:75 self.verificationErrors.append(str(e))76 def is_element_present(self, how, what):77 try:78 self.driver.find_element(by=how, value=what)79 except NoSuchElementException:80 return False81 return True82 def select_single_item(self, field_id, value):83 Select(self.driver.find_element_by_id(field_id)).select_by_value(value)84 def select_multi_items(self, field_id, *values):85 options = Select(self.driver.find_element_by_id(field_id))86 for value in values:87 options.select_by_value(value)88 def select_all_items(self, field_id):89 options = Select(self.driver.find_element_by_id(field_id)).options90 for option in options:91 if not option.is_selected():92 option.click()93 def is_alert_present(self):94 try:95 self.driver.switch_to_alert()96 except NoAlertPresentException:...

Full Screen

Full Screen

test_users.py

Source:test_users.py Github

copy

Full Screen

...20 # def test_create_and_delete_account(self):21 # # Create account22 # self.driver.get(var.home_page)23 # self.driver.find_element_by_css_selector('a.btn.sign-up').click()24 # self.select_single_item('id_username', '1')25 # self.set_text_id('id_profile_colour', '#00ffff')26 # self.select_single_item('id_security_question_1', '1')27 # self.set_text_id('id_security_answer_1', 'Answer 1')28 # self.select_single_item('id_security_question_2', '2')29 # self.set_text_id('id_security_answer_2', 'Answer 2')30 # self.set_text_id('id_password1', 'asdasd')31 # self.set_text_id('id_password2', 'asdasd')32 # self.driver.find_element_by_css_selector('div.form-footer > input.btn-submit').click()33 # time.sleep(3)34 # # Delete account35 # self.driver.find_element_by_css_selector("a.mm-next.mm-fullsubopen").click()36 # self.driver.find_element_by_link_text('My settings').click()37 # self.driver.find_element_by_link_text('Delete Profile').click()38 # self.set_text_id('id_current_password', 'asdasd')39 # self.driver.find_element_by_css_selector('input.btn-submit').click()40 # def test_follow_unfollow_user(self):41 # self.login(var.u1.username, var.u1.password)42 # self.driver.get(var.testing2_user_page) # Go to u2 profile...

Full Screen

Full Screen

test_demo.py

Source:test_demo.py Github

copy

Full Screen

...26 def test_add_to_cart_red_font(self, main_page, parametrized_index):27 res = main_page.font_color(parametrized_index, 'add_to_cart')28 assert res == 'red'29 @pytest.fixture(scope='class', params=_ids.keys(), ids=_ids.values())30 def select_single_item(self, main_page, request) -> int:31 """Selects a parametrized item by index and returns the index value"""32 main_page.add_or_remove_item(index_=request.param)33 yield request.param34 if main_page.item_text(index_=request.param) == 'REMOVE':35 main_page.add_or_remove_item(index_=request.param)36 def test_add_item_to_the_cart(self, main_page, select_single_item):37 item_selected = main_page.item_text(index_=select_single_item)38 assert item_selected == 'REMOVE'39 def test_black_color_remove_btn(self, main_page, select_single_item):40 item_selected = main_page.font_color(index_=select_single_item, object_element='add_to_cart')41 assert item_selected == 'black'42 def test_cart_label_is_one(self, main_page, select_single_item):43 assert main_page.cart_icon_content() == '1'44 @pytest.fixture(scope='class')...

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 lettuce_webdriver 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