Skip to content

Instantly share code, notes, and snippets.

@mare1012
Created June 13, 2017 11:50
Show Gist options
  • Save mare1012/1f67e5c10507932d9823651405a56aa8 to your computer and use it in GitHub Desktop.
Save mare1012/1f67e5c10507932d9823651405a56aa8 to your computer and use it in GitHub Desktop.
test script for login
from appium import webdriver
import time
# setup the webdriver
desired_caps = {
'platformName': 'ios',
'platformVersion':'10.3',
'deviceName':'iPhone 6s',
'automationName':'XCUITest',
'browserName': 'Safari',
'startIWDP':True,
'webkitResponseTimeout': 35000,
'safariInitialUrl':'https://mm.web.de',
'useNewWDA': False,
'usePrebuiltWDA': True,
'showXcodeLog': True,
#'webDriverAgentUrl':'http://localhost:8100',
'xcodeOrgId':'XXXXXXXXXX',
'xcodeSigningId':'iPhone Developer',
'udid': 'auto',
'autoWebView': True,
'clearSystemFiles': True
}
#setup the web driver
driver = webdriver.Remote('http://localhost:4491/wd/hub', desired_caps)
# suspend the execution for 10 seconds
time.sleep(10)
# navigate to the page
driver.get('https://mm.web.de')
# suspend the execution for 10 seconds
time.sleep(10)
# click inbox symbol on the homepage
el = driver.find_element_by_xpath("//*[@class='login-button']")
el.click()
# suspend the execution for 5 seconds
time.sleep(5)
# one more navigate to the page, to avoid the ad
driver.get('https://mm.web.de')
# click inbox symbol on the homepage
el = driver.find_element_by_xpath("//button[@class='login-button']")
el.click()
# suspend the execution for 2 seconds
time.sleep(2)
# input the user name
user = driver.find_element_by_xpath("//input[@name='username']")
user.clear()
user.send_keys('xxxxxxx')
# input password
pw = driver.find_element_by_xpath("//input[@name='password']")
pw.clear()
pw.send_keys('xxxxx')
# click login button
lb = driver.find_element_by_xpath("//input[@name='login']")
lb.click()
# suspend the execution for 5 seconds
time.sleep(5)
# click logut button
lb = driver.find_element_by_xpath("//i[@title='Logout']")
lb.click()
# suspend the execution for 5 seconds
time.sleep(5)
# close the driver
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment