Python 3.x str对象没有属性';获取';
我在selenium python中使用unittest示例 尝试谷歌没有得到正确的解决方案Python 3.x str对象没有属性';获取';,python-3.x,selenium,Python 3.x,Selenium,我在selenium python中使用unittest示例 尝试谷歌没有得到正确的解决方案 from selenium import webdriver import unittest #import HtmlTestRunner class googlesearch(unittest.TestCase): driver = 'driver' @classmethod def setupClass(self): self.driver = w
from selenium import webdriver
import unittest
#import HtmlTestRunner
class googlesearch(unittest.TestCase):
driver = 'driver'
@classmethod
def setupClass(self):
self.driver = webdriver.Chrome(chrome_options=options)
self.driver.implicitly_wait(10)
self.driver.maximize_window()
def test_search_automationstepbystep(self):
self.driver.get("https://google.com")
self.driver.find_element_by_name("q").send_keys("Automation Step By step")
self.driver.find_element_by_name("btnk").click()
def test_search_naresh(self):
self.driver.get("https://google.com")
self.driver.find_element_by_name("q").send_keys("Naresh")
self.driver.find_element_by_name("btnk").click()
@classmethod
def teardownClass(self):
self.driver.close()
self.driver.quit()
print("Test completed")
if __name__== "__main__":
unittest.main()
正如前面提到的@Error-Syntactical懊悔,由于类中的第一行代码,驱动程序是一个字符串
如果您计划全局访问驱动程序,请确保将
驱动程序
声明为全局。驱动程序='driver'
因此驱动程序
是一个str
。您对在字符串上调用get
有什么期望?