Selenium webdriver 显示对象的属性

Selenium webdriver 显示对象的属性,selenium-webdriver,Selenium Webdriver,在StackOverFlow的登录页面上,单击“使用堆栈交换登录”链接可使“忘记密码”链接不可见,因此显示属性从block变为none 忘记密码 更改为 忘记密码 如何使用getAttributes()方法验证这一点 谢谢 您可以更好地使用,比如使用python: from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.commo

在StackOverFlow的登录页面上,单击“使用堆栈交换登录”链接可使“忘记密码”链接不可见,因此显示属性从block变为none

忘记密码

更改为

忘记密码

如何使用getAttributes()方法验证这一点

  • 谢谢
    • 您可以更好地使用,比如使用
      python

      from selenium import webdriver
      from selenium.webdriver.support.ui import WebDriverWait
      from selenium.webdriver.common.by import By
      from selenium.webdriver.support import expected_conditions as EC
      
      driver = webdriver.Chrome()
      driver.get("https://stackoverflow.com/users/login")
      
      #Find and click button
      stack_exchange_button = driver.find_element_by_xpath("//span[text()='Log in using Stack Exchange']")
      stack_exchange_button.click()
      
      #Let's wait up to 10 seconds for forgot link to be invisible
      WebDriverWait(driver, 10).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, "a[id='forgot-password']")))
      
      print "Link is invisible"
      
      好的,如果您仍然不想使用waits for expected condition,那么可以检查以下元素是否存在:
      //a[@id='forget-password'][contains(@style,'display:none')]