如何解决错误AttributeError: \'NoneType\' object has no attribute \'click\'?它的失败在于self.home.get_you_button().click(). 当我没有创建页面对象类时,它\xe2\x80\x99s 工作正常...它单击“You”按钮,没有任何错误,但通过使用 POM,它\xe2\x80\x99s 失败。网址是https://huew.co/
代码试验:
\n\nfrom selenium.webdriver.support import expected_conditions\nfrom selenium.webdriver.support.wait import WebDriverWait\n\nclass HomePage():\n\n def __init__(self,driver):\n self.driver = driver\n\n def wait_for_home_page_to_load(self):\n wait =WebDriverWait(self.driver,30)\n wait.until(expected_conditions.visibility_of(self.driver.find_element_by_tag_name(\'html\')))\n\n def get_you_button(self):\n\n try:\n element = self.driver.find_element_by_xpath("//div[@class=\'desktop-public-header\']/a[@ng-controller=\'UserNavigationInteractionCtrl\'][6]")\n\n except:\n return None\nRun Code Online (Sandbox Code Playgroud)\n