这个问题已经以类似的方式提出,但没有相同的参数,一些答案是混合的。我目前有geckowebdriver,硒3.5.9。用python 2.7.10。我在pycharm中运行了以下测试:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import unittest
class LoginTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.get("https://www.rosoka.com/")
def test_Login(self):
driver = self.driver
rosokaUsername = "dsmith"
rosokaPassword = "Whorunit1!"
loginFieldID = "edit-name"
passFieldID = "edit-pass"
loginButtonXpath = "//input[@value ='Log in']"
loginFieldElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id(loginFieldID))
passFieldElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_id(passFieldID))
loginButtonElement = WebDriverWait(driver, 10).until(lambda driver: driver.find_element_by_xpath(loginButtonXpath))
loginFieldElement.clear()
loginFieldElement.send_keys(rosokaUsername)
passFieldElement.clear()
passFieldElement.send_keys(rosokaPassword)
loginButtonElement.click()
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
我得到了:
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
InvalidElementStateException: Message: Element is not currently interactable and may not be manipulated
有什么想法吗?
答案 0 :(得分:0)
当我导航到该网站时,登录表单字段不可见,我必须单击"用户门户"链接看到他们。所以你的脚本应该做同样的事情。