繁体   English   中英

AttributeError:模块“selenium.webdriver”在 Selenium webdriver 中没有属性“w3c”

[英]AttributeError: module 'selenium.webdriver' has no attribute 'w3c' in Selenium webdriver

我正在尝试从键盘进行操作,我想从键盘按TAB键进行操作,但它对我来说是这个错误消息

AttributeError:模块“selenium.webdriver”没有属性“w3c”

这是我的代码

from selenium import webdriver
import unittest
import time
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from Pages.loginPage import LoginPage

class createDevice(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.driver = webdriver.Chrome(executable_path="C:/Users/Admin/PycharmProjects/admin/Drivers/chromedriver.exe")
        cls.driver.maximize_window()
        driver = cls.driver
        driver.get("https://admin-helper-f21c1.web.app/login")
        login = LoginPage(driver)
        login.enter_email("admin@gmail.com")
        login.enter_password("123456")
        login.click_login()
        cls.driver.implicitly_wait(10)

    def test_create_device_03(self):
        self.driver.find_element_by_xpath('//*[@id="sidebar"]/ul/li[2]/a').click()
        time.sleep(2)
        self.driver.find_element_by_xpath("//main//div/button[@type='button']").click()
        self.driver.find_element_by_xpath("//input[@id='name']").send_keys(" ")
        action = ActionChains(webdriver)
        action.send_keys(Keys.TAB)
        self.driver.find_element_by_xpath("//div[text()=' Device name is required. ']").is_displayed()
        print("'Device name is required.' displayed")
        time.sleep(2)

谁能向我解释这是什么意思,我该如何解决这个问题? 我已经在搜索它,但我没有找到适合我的答案。 请帮我! 太感谢了

ActionChains()接受WebDriver的实例作为参数。

在这个用例中, WebDriver实例是self.driver ,你已经通过了webdriver

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM