from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
class LoginPage():
def __init__(self, driver):
self.driver = driver
def get_username_textbox(self):
try:
return self.driver.find_element_by_id('email')
except:
return None
def get_password_textbox(self):
try:
return self.driver.find_element_by_id('pass')
except:
return None
def get_login_button(self):
try:
return self.driver.find_element_by_id("loginbutton")
except:
return None
def wait_for_login_page(self):
wait = WebDriverWait(self.driver, 30)
element = self.driver.title("Facebook – log in or sign up")
wait.until(EC.title_is(element))
答案 0 :(得分:0)
EC的title_is方法只接受文本/字符串参数。
您可以按照以下方式进行更改。
def wait_for_login_page(self):
wait = WebDriverWait(self.driver, 30)
wait.until(EC.title_is("Facebook – log in or sign up"))
答案 1 :(得分:0)
driver.title返回一个字符串 我相信你想要做的更多内容是:
assert self.driver.title == "Facebook – log in or sign up"