Python 属性错误:';Dlink&x27;对象没有属性';浏览器驱动程序&x27;
我用python创建了一个类:Python 属性错误:';Dlink&x27;对象没有属性';浏览器驱动程序&x27;,python,Python,我用python创建了一个类: class Dlink(object): def __init__(self, server_ip): self.broswer_driver = webdriver.Chrome() self.base_url = "http://" + server_ip self.broswer_driver.implicitly_wait(30) def dlink_change_channel(self, channel): ..
class Dlink(object):
def __init__(self, server_ip):
self.broswer_driver = webdriver.Chrome()
self.base_url = "http://" + server_ip
self.broswer_driver.implicitly_wait(30)
def dlink_change_channel(self, channel):
.......
actions = ActionChains(self.browser_driver)
actions.moveToElement(self.broswer_driver.find_element_by_xpath("//a[@href'802.11n']")).click().perform();
我正在从另一个文件实例化Dlink:
dlink_router = dlink.Dlink(DLINK_IP)
result = dlink_router.dlink_change_channel(channel)
我正在尝试单击打开的网页上的下拉选项。我得到以下错误:
文件wifi\u thpt/dlink.py,第50行,在dlink\u change\u channel属性中
错误:“Dlink”对象没有属性“browser\u driver”
为什么我会犯这个错误?浏览器驱动程序是Dlink类的一个属性。我认为您的属性是
浏览器驱动程序
,而不是浏览器驱动程序
。您在那里犯了一个拼写错误。我认为您的属性是broswer\u driver
,而不是browser\u driver
。你在那儿犯了一个拼写错误