How to use location_should_be method in robotframework-pageobjects

Best Python code snippet using robotframework-pageobjects_python

keywords.py

Source:keywords.py Github

copy

Full Screen

...3bi = BuiltIn()4sl = BuiltIn().get_library_instance("SeleniumLibrary")5def goto_login_form():6 sl.click_link('css=div.telef > a')7 sl.location_should_be('http://obod.com.ua/login.html')8 sl.element_should_contain('css=#content > span',9 'Регистрация/Вход в 1 клик')10 sl.element_should_contain('css=form > div > div > p',11 'Войти в Личный Кабинет')12def next_and_check_log_on_invalid():13 sl.click_element('css=div.right > form > div > button')14 sl.location_should_be('http://obod.com.ua/login.html')15 sl.element_should_contain('css=#container > div.warning',16 'Неправильно заполнены поля E-Mail и/или пароль!')17def goto_registration_form():18 sl.click_link('css=div.telef > a')19 sl.location_should_be('http://obod.com.ua/login.html')20 sl.element_should_contain('css=#content > span',21 'Регистрация/Вход в 1 клик')22 sl.element_should_contain('css=p:nth-child(1) > b',23 'Регистрация')24 sl.click_element('css=div.left > div > a')25 sl.location_should_be('http://obod.com.ua/index.php?route=account/simpleregister')26 sl.element_should_contain('css=#content > h1',27 'Быстрая регистрация')28def next_and_check_reg_on_invalid():29 sl.click_element('css=#simpleregister > div > div > a > span')30 sl.location_should_be('http://obod.com.ua/index.php?route=account/simpleregister')31 sl.element_should_contain('css=#content > h1',32 'Быстрая регистрация')33 sl.element_should_contain('css=tr:nth-child(1) > td.simplecheckout-customer-right > span',34 'Ошибка в адресе электронной почты')35 sl.element_should_contain('css=tr:nth-child(2) > td.simplecheckout-customer-right > span',36 'В пароле должно быть от 4 до 20 символов!')37 sl.element_should_contain('css=tr:nth-child(3) > td.simplecheckout-customer-right > span',38 'Имя должно быть от 1 до 30 символов')39 sl.element_should_contain('css=tr:nth-child(4) > td.simplecheckout-customer-right > span',40 'Телефон должен быть в формате +38(0xx)xxx-xx-xx')41def valid_login_and_check(email, password):42 sl.input_text('css=input[type=text]:nth-child(3)', email)43 sl.input_password('css= input[type=password]:nth-child(5)', password)44 sl.click_element('css=form >div > button')45 sl.location_should_be('http://obod.com.ua/index.php?route=account/tmdaccount')46 sl.element_should_contain('css=div.column3 > span.zag3', 'Мой Аккаунт')47def enter_password_only(valid_login_password):48 sl.input_password('css= input[type=password]:nth-child(5)',49 valid_login_password)50def enter_email_only(valid_login_email):51 sl.input_password('css=input[type=text]:nth-child(3)',52 valid_login_email)53def enter_valid_email_and_invalid_password(valid_login_email,54 invalid_login_password):55 sl.input_text('css=input[type=text]:nth-child(3)',56 valid_login_email)57 sl.input_password('css= input[type=password]:nth-child(5)',58 invalid_login_password)59def enter_invalid_email_and_valid_password(invalid_login_email,60 valid_login_password):61 sl.input_text('css=input[type=text]:nth-child(3)',62 invalid_login_email)63 sl.input_password('css= input[type=password]:nth-child(5)',64 valid_login_password)65def replacement_email_and_password(valid_login_email,66 valid_login_password):67 sl.input_text('css=input[type=text]:nth-child(3)',68 valid_login_password)69 sl.input_password('css= input[type=password]:nth-child(5)',70 valid_login_email)71def login_with_system_code_on_email(valid_login_password):72 sl.input_text('css=input[type=text]:nth-child(3)',73 '<script>alert</script>')74 sl.input_password('css= input[type=password]:nth-child(5)',75 valid_login_password)76def check_if_login_fields_are_saved(valid_login_email,77 valid_login_password):78 sl.input_text('css=input[type=text]:nth-child(3)',79 valid_login_email)80 sl.input_password('css=input[type=password]:nth-child(5)',81 valid_login_password)82 sl.go_back()83 sl.location_should_be('http://obod.com.ua/velomagazin-hmelnickiy.html')84 sl.element_should_contain('css=#content > h1',85 'Веломагазин Хмельницкий')86 sl.click_link('css=div.telef > a')87 sl.location_should_be('http://obod.com.ua/login.html')88 sl.element_should_contain('css=#content > span',89 'Регистрация/Вход в 1 клик')90 sl.element_should_contain('css=form > div > div > p',91 'Войти в Личный Кабинет')92def registration_new_user(reg_valid_password,93 reg_valid_name,94 reg_valid_tel):95 reg_email_random_and_valid = 'test-obod' + str(random.randint(100, 999)) + '@mailintator.com'96 sl.input_text('css=#registration_main_email',97 reg_email_random_and_valid)98 sl.input_password('css= input[type=password]',99 reg_valid_password)100 sl.input_text('css=#registration_main_firstname',101 reg_valid_name)102 sl.press_keys('css=#registration_main_telephone',103 reg_valid_tel)104 sl.click_element('css=#simpleregister > div > div > a > span')105 sl.location_should_be('http://obod.com.ua/index.php?route=account/tmdaccount')106 sl.element_should_contain('css=div.column3 > span.zag3',107 'Мой Аккаунт')108def registration_user_with_only_spaces_in_field():109 sl.input_text('css=#registration_main_email',110 ' ')111 sl.input_password('css= input[type=password]',112 ' ')113 sl.input_text('css=#registration_main_firstname',114 ' ')115 sl.press_keys('css=#registration_main_telephone', ' ')116def registration_user_with_spaces_and_valid_data_in_field(reg_valid_password,117 reg_valid_name,118 reg_valid_tel):119 spcs_reg_email_random_and_valid = ' test-obod' + str(random.randint(100, 999)) + '@mailintator.com '120 spcs_password = ' ' + reg_valid_password + ' '121 spcs_name = ' ' + reg_valid_name + ' '122 spcs_telephone = ' ' + reg_valid_tel + ' '123 sl.input_text('css=#registration_main_email',124 spcs_reg_email_random_and_valid)125 sl.input_text('css= input[type=password]',126 spcs_password)127 sl.input_text('css=#registration_main_firstname',128 spcs_name)129 sl.press_keys('css=#registration_main_telephone',130 spcs_telephone)131 sl.click_element('css=#simpleregister > div > div > a > span')132 sl.location_should_be('http://obod.com.ua/index.php?route=account/tmdaccount')133 sl.element_should_contain('css=div.column3 > span.zag3',134 'Мой Аккаунт')135def check_if_registration_fields_are_saved(reg_valid_password,136 reg_valid_name,137 reg_valid_tel):138 reg_email_random_and_valid = 'test-obod' + str(random.randint(100, 999)) + '@mailintator.com'139 sl.input_text('css=#registration_main_email',140 reg_email_random_and_valid)141 sl.input_text('css= input[type=password]',142 reg_valid_password)143 sl.input_text('css=#registration_main_firstname',144 reg_valid_name)145 sl.press_keys('css=#registration_main_telephone',146 reg_valid_tel)147 sl.go_back()148 sl.element_should_contain('css=#content > span',149 'Регистрация/Вход в 1 клик')150 sl.location_should_be('http://obod.com.ua/login.html')151 sl.element_should_contain('css=p:nth-child(1) > b',152 'Регистрация')153 sl.click_link('css=div.left > div > a')154 sl.location_should_be('http://obod.com.ua/index.php?route=account/simpleregister')155 sl.element_should_contain('css=#content > h1', 'Быстрая регистрация')156def go_to_shop_bicycle_parts_page():157 sl.click_element('css=li.mega-menu-mixed.main-menu-item-3 > a > span')158 sl.location_should_be('http://obod.com.ua/zapchasti')159 sl.element_should_contain('css=#content > h1',160 'Велозапчасти, Запчасти на Велосипед')161def go_to_shop_accessories_page():162 sl.click_element('css=li.mega-menu-mixed.main-menu-item-4 > a')163 sl.wait_until_location_is_not('http://obod.com.ua/velomagazin-hmelnickiy.html')164 sl.location_should_be('http://obod.com.ua/aksessuary')165 sl.element_should_contain('css=#content > h1',166 'Аксессуары для Велосипеда')167def buy_first_place_on_shop():168 sl.click_element('css=div:nth-child(1) > div > div.product-details > div.cart > a')169def go_to_cart_page_with_product():170 sl.wait_until_element_is_enabled('css=body > div.ui-pnotify', '7')171 sl.click_element('css=body > div.ui-pnotify > div > div.ui-pnotify-text > div > a')172def add_product_like_first():173 sl.click_element('css=td.quantity > img:nth-child(3)')174 sl.textfield_value_should_be('css=td.quantity > input[type=text]', '2')175def check_on_two_position_in_cart():176 sl.element_should_be_visible('css=#simplecheckout_cart > table > tbody > tr:nth-child(1)')177 sl.element_should_be_visible('css=#simplecheckout_cart > table > tbody > tr:nth-child(2)')178def delete_first_place_in_cart():...

Full Screen

Full Screen

CommonSteps.py

Source:CommonSteps.py Github

copy

Full Screen

...49def step_impl(context, seconds):50 sleep(float(seconds))51@when("Client profile has loaded")52def step_impl(context):53 context.driver.location_should_be(PROFILE_URL)54 context.driver.find_by_id('firstName')55@step('Element with ID "{html_id}" should have value "{expected_value}"')56def step_impl(context, html_id, expected_value):57 actual_value = context.driver.find_by_id(html_id).get_attribute('value')58 assert_that(actual_value, equal_to(expected_value))59@step('Element with name "{html_name}" should have value "{expected_value}"')60def step_impl(context, html_name, expected_value):61 actual_value = context.driver.find_by_name(html_name).get_attribute('value')62 assert_that(actual_value, equal_to(expected_value))63@then("User is on Edit Appointment page")64def step_impl(context):65 context.driver.location_should_be(EDIT_APPOINTMENT_URL)66@then('Edit appointment dialog shows message "{expected_message}"')67def step_impl(context, expected_message):68 context.driver.find_by_name('edit-appointment-dialog')69 actual_message = context.driver.find_by_name('edit-appointment-dialog-msg').text70 assert_that(actual_message, equal_to(expected_message))71@when('User sets text for element with ID "{html_id}" to "{text}"')72def step_impl(context, html_id, text):73 context.driver.set_text_of_el_with_id(html_id, text)74@when('User sets text for element with name "{html_name}" to "{text}"')75def step_impl(context, html_name, text):76 context.driver.set_text_of_el_with_name(html_name, text)77@step(78 'Staff member enters user registration data "{first_name}" "{surname}" "{username}" "{email}" "{address1}" '79 '"{address2}" "{city}" "{province}" "{postal_code}"')80def step_impl(context, first_name, surname, username, email, address1, address2, city, province, postal_code):81 # Confirm on user registration page82 context.driver.location_should_be(REGISTER_URL)83 # Fill in form84 context.driver.set_text_of_el_with_name('first-name', first_name)85 context.driver.set_text_of_el_with_name('surname', surname)86 context.driver.set_text_of_el_with_name('username', username)87 context.driver.set_text_of_el_with_name('email', email)88 context.driver.set_text_of_el_with_name('address', address1)89 context.driver.set_text_of_el_with_name('address2', address2)90 context.driver.set_text_of_el_with_name('city', city)91 context.driver.set_text_of_el_with_name('postal-code', postal_code)92 # Make selection on province dropdown93 province_el = context.driver.find_by_name('province')94 context.driver.set_dropdown_selection(province_el, province)95 # Submit form96 context.driver.find_by_name('register-btn').click()97@step("Staff member is on User Registration page")98def step_impl(context):99 context.driver.open(REGISTER_URL)100 context.driver.location_should_be(REGISTER_URL)101@step("Login fields have loaded")102def step_impl(context):103 context.driver.location_should_be(LOGIN_URL)...

Full Screen

Full Screen

driver_assertion.py

Source:driver_assertion.py Github

copy

Full Screen

1from logigear.core import browserManagementKeywords2class DriverAssertion():3 4 def location_should_be(self, url, message=None):5 browserManagementKeywords.location_should_be(url, message)6 7 def location_should_contain(self, expected, message=None):8 browserManagementKeywords.location_should_contain(expected, message)9 10 def title_should_be(self, title, message=None):11 browserManagementKeywords.title_should_be(title, message)12 ...

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 robotframework-pageobjects 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