Ejemplo n.º 1
0
class Login():
    def __init__(self):
        self.browser = {}

    @keyword
    def open_browser(self, name='chrome'):
        self.browser = Browser(browser=name)

    @keyword
    def open_on_sauce(self):
        caps = {
            'platformName': 'Windows 10',
            'plaformVersion': 'latest',
            'browserName': 'chrome'
        }

        username = environ.get('SAUCE_USERNAME', None)
        access_key = environ.get('SAUCE_ACCESS_KEY', None)

        selenium_endpoint = "http://ondemand.saucelabs.com/wd/hub"

        caps['username'] = username
        caps['accesskey'] = access_key
        caps['name'] = 'Robot Nerodia - Login'

        executor = RemoteConnection(selenium_endpoint, resolve_ip=False)
        remote = webdriver.Remote(command_executor=executor,
                                  desired_capabilities=caps)

        self.browser = Browser(browser=remote, desired_capabilities=caps)

    @keyword
    def go_to_login(self):
        self.browser.goto(BASE_TEST_URL + "login")

    @keyword
    def login_as(self, username, password):
        self.browser.input(id='username').send_keys(username)
        self.browser.input(id='password').send_keys(password)
        self.browser.button(class_name='radius').click()

    @keyword
    def is_error_message_visible(self):
        assert self.browser.element(class_name='error').present

    @keyword
    def is_login_successful(self):
        assert self.browser.element(class_name='success').present

    @keyword
    def close_browser(self):
        self.browser.quit()
Ejemplo n.º 2
0
from nerodia.browser import Browser

br = Browser(browser="firefox")
br.goto("https://www.w3schools.com/html/html_form_elements.asp")
br.element(css="textarea[cols='30']").send_keys("hello world")
br.element(css="textarea[cols='30']").send_keys([COMMAND + 't'])

browser.close()
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
# coding=utf-8
from nerodia.browser import Browser

browser = Browser(browser="firefox")
browser.goto("http://toolsqa.com/automation-practice-form/")

if browser.title == "Demo Form for practicing Selenium Automation":
    print(browser.title)

text1 = browser.element(class_name="h1-size")
print(text1)

text2 = browser.element(
    css=
    "#content > div.vc_row.wpb_row.vc_row-fluid.dt-default > div > div > div > div.vc_message_box.vc_message_box-standard.vc_message_box-rounded.vc_color-info > p:nth-child(2) > em > strong"
)
print(text2)

text3 = browser.element(
    text=
    "Always click on the ads display at the right side, this is how we manage the website’s expenses and bring free content for the beginners."
)
print(text3.text)

browser.link(text="Partial Link Test").wait_until_present().click()
browser.link(text="Link Test").wait_until_present().click()
browser.back()

browser.text_field(name="firstname").wait_until_present().set("Fname")
browser.text_field(name="firstname").clear()
browser.select_list(id="continents").select("Antartica")