fake = Faker() # So we can use fake.name() instead of Faker().name() browser.text_field(id='address_first_name').set(fake.first_name()) browser.text_field(id='address_last_name').set(fake.last_name()) browser.text_field(id='address_street_address').set(fake.street_address()) browser.text_field(id='address_secondary_address').set( fake.secondary_address()) browser.text_field(id='address_city').set(fake.city()) # Select list elements can select by either `text` or `value` browser.select_list(id='address_state').select(fake.state()) browser.text_field(id='address_zip_code').set(fake.postcode()) # Radio buttons can be selected with `text` or `label` locators browser.radio(text='Canada').set() # Date Field elements accept Date objects birthday = fake.date_of_birth() browser.date_field(id='address_birthday').set(birthday) age = fake.date_time_this_year().year - birthday.year browser.text_field(id='address_age').set(age) browser.text_field(id='address_website').set(fake.url()) # File Field elements upload file with the '#set' method, but require the full system path file_name = 'nerodia_example.txt' file = open(file_name, 'w+').close() path = os.path.realpath(file_name) browser.file_field(id='address_picture').set(path)
from nerodia.browser import Browser browser = Browser(browser='firefox') browser.goto("http://toolsqa.com/automation-practice-form/") print(browser.title) text1 = browser.element(class_name='h1-size') print(text1.text) browser.radio(id="sex-0").set() browser.radio(id="sex-1").set() browser.radio(id="exp-2").set() browser.close()