我不想在代码中硬编码被测应用程序的URL,而是想在命令行中将其作为参数传递。还有用户名和密码
目前我得到下面的错误
错误:找不到文件:
pytest -v -s --html=.\Reports\report.html test_practise.py https://testurl
下面是我的登录功能:
class LoginPage():
def __init__(self, driver):
self.driver = driver
self.url = 'https://test-url'
def go(self):
self.driver.get(self.url)
def enter_username(self,text):
username_xpath = "//input[@id='emailOrUsername']"
WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.XPATH, username_xpath))).send_keys(text)
def enter_password(self,text):
password_xpath = "//input[@id='pass']"
WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.XPATH, password_xpath))).send_keys(text)
def click_login_button(self):
login_btn_xpath = "//span[contains(text(),'Login')]"
self.driver.find_element_by_xpath(login_btn_xpath).click()
def get_login_btn_text(self):
login_btn_xpath = "//span[contains(text(),'Login')]"
login_btn_text = self.driver.find_element_by_xpath(login_btn_xpath).text
return login_btn_text
有一个内置模块argparse。查看教程by the link
结果如下: $python3 prog.py帮助 用法:prog.py[-h]echo
相关问题 更多 >
编程相关推荐