我正在用python研究硒,在一个教程中我找到了以下代码。
from selenium import webdriver
from time import gmtime, strftime
import unittest
#from builtins import classmethod
class RegisterNewUser(unittest.TestCase):
#@classmethod
def setUp(self):
self.driver = webdriver.Firefox
self.driver.implicitly_wait(30)
self.driver.maximize_window()
# navigate to the application home page
self.driver.get("http://demo-store.seleniumacademy.com/")
def test_register_new_user(self):
driver = self.driver
pass
def tearDown(self):
self.driver.quit()
if __name__ == "__main__":
unittest.main(verbosity=2)
它抛出一个错误:
File "register_new_user.py", line 10, in setUp
self.driver.implicitly_wait(30)
TypeError: implicitly_wait() missing 1 required positional argument: 'time_to_wait'
我尝试添加注释掉的代码(classmethod
),但未做任何更改。没有test_register_new_user
不会给出错误。
我正在使用python 3.6.4,selenium 3.141(和geckodriver 0.23)
答案 0 :(得分:3)
您的问题在上面一行:
IF ( EXISTS (SELECT * from jdwf_alien_jobs where jaj_jno = '7200000') ,
UPDATE jdwf_orders_main set jom_adv_name = 'IAM OP' where jom_job_no = '7200000',
UPDATE jdwf_orders_main set jom_adv_name = 'IAM Noob' where jom_job_no = '7200000');
这不会创建浏览器对象。它只是将self.driver = webdriver.Firefox
设置为类self.driver
,这意味着webdriver.Firefox
试图以静态方式使用self.driver.implicitly_wait(30)
,即implicitly_wait
,因此它丢失了实例,即webdriver.Firefox.implicitly_wait(30)
。
您缺少webdriver.Firefox.implicitly_wait(an_actual_browser, 30)
:
()