小编Car*_*elo的帖子

Selenium - visibility_of_element_located:__ init __()只需2个参数(给定3个)

我在使用Selenium Python Bindings的测试代码中收到此错误:

>           twitter_campaigns = wait.until(EC.visibility_of_element_located(By.CSS_SELECTOR, TWITTER_CAMPAIGNS))
E           TypeError: __init__() takes exactly 2 arguments (3 given)
Run Code Online (Sandbox Code Playgroud)

这就是我执行的:

class TestTwitter(TestLogin, TestBuying):

    def setup(self, timeout=10):
        self.driver = webdriver.Firefox()
        self.driver.get(BASEURL)
        self.driver.implicitly_wait(timeout)

    def test_campaigns_loaded(self, timeout=10):
        self.signin_action()
        self.view_twitter_dashboard()
        self.select_brand()
        wait = WebDriverWait(self.driver, timeout)
        twitter_campaigns = wait.until(EC.visibility_of_element_located(By.CSS_SELECTOR, TWITTER_CAMPAIGNS))
        assert True == twitter_campaigns

    def teardown(self):
        self.driver.close()
Run Code Online (Sandbox Code Playgroud)

所以我想知道为什么我得到了上述错误,在我没有定义__init__()方法的所有类中,我将setUp和tearDown方法定义为pytest跟随.任何想法为什么要采取3 args?

python selenium pytest selenium-webdriver

6
推荐指数
1
解决办法
4587
查看次数

标签 统计

pytest ×1

python ×1

selenium ×1

selenium-webdriver ×1