Selenium2中,WebDriverWait中expected_conditions.element_to_be_clickable()参数传递


今天遇到一个很奇怪的问题,selenium2中使用WebDriverWait来等待元素出现,就使用了expected_conditions.element_to_be_clickable(*loc),由于参数loc是从Excel获取的,本身是个list,所以我就自作聪明的传入了*loc,也就是:

    def click(loc):
        try:
            ele = WebDriverWait(self.driver,30).until(expected_conditions.element_to_be_clickable(*loc))
            ele.click()
        except:
            print u'元素点击失败!'
            self.saveScreenShot_error('元素点击失败')
结果可想而知,报错提示只需要两个参数,结果传了3个。。。。

后来查看代码发现,这块和drive.find_element(*loc)不同,这里只需要传入list就好了,底层已经实现了*By,所以实在多此一举。

猜你喜欢

转载自blog.csdn.net/ljl6158999/article/details/70808359