我用这个帖子
http://www.autotest.org.ua/first-autotest-with-selenium-webdriver-and-python/
在皮查姆做项目
代码测试:
from selenium import webdriver
import unittest
from selenium.webdriver.common.keys import Keys
class GoogleSearch(unittest.TestCase):
def setUpp(self):
self.driver = webdriver.Chrome(executable_path="C:\Python37-32\geckodriver-v0.23.0-win64\geckodriver.exe")
self.driver.get('https://www.google.by')
self.driver.maximize_window()
self.driver.implicitly_wait(10)
def test_01(self):
driver = self.driver
input_field = driver.find_element_by_class_name('class="gLFyf gsfi"')
input_field.send_keys('python')
input_field.send_keys(Keys.ENTER)
错误:
FAILED (errors=1)
Error
Traceback (most recent call last):
File "C:\Python37-32\lib\unittest\case.py", line 59, in testPartExecutor
yield
File "C:\Python37-32\lib\unittest\case.py", line 615, in run
testMethod()
File "D:\QA\untitled\test.py", line 13, in test_01
driver = self.driver
AttributeError: 'GoogleSearch' object has no attribute 'driver'
Process finished with exit code 1
我不知道怎么解决。。。