简体   繁体   English

使用Python的Selenium Web驱动程序中的“ AttributeError”

[英]“AttributeError” in Selenium Web Driver using Python

I'm writing simple test for calculator on Python. 我正在Python上为计算器编写简单的测试。 I'm getting this error AttributeError: 'CalculatorTesting' object has no attribute 'driver' . 我收到此错误AttributeError: 'CalculatorTesting' object has no attribute 'driver' I'm a newbie in python so please show me my mistake. 我是python的新手,所以请告诉我我的错误。 Here is my code: 这是我的代码:

def SetUp(self):
    self.driver = webdriver.Chrome('E:\chromedriver.exe')
    self.driver.get('http://qa-test.klika-tech.com/');

def test_01(self):
    driver = self.driver
    self.driver.find_element_by_xpath('/html/body/div[2]/ul[1]/li[5]').click()
    self.driver.find_element_by_xpath('/html/body/div[2]/ul[2]/li[5]').click()
    self.driver.find_element_by_xpath('/html/body/div[2]/ul[1]/li[5]').click()
    self.driver.find_element_by_xpath('/html/body/div[2]/ul[2]/li[7]').click()
    self.result = driver.find_element_by_xpath('//*[@id="display"]').text

    assert self.result is "10"

def ShutDown(self):
    self.driver.quit()

all xpaths are correct. 所有xpath都是正确的。

Okay i found a mistake. 好吧,我发现了一个错误。 There was big 'S' in 'setUp' class. 在“ setUp”类中有一个很大的“ S”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用python的selenium web驱动程序选择复选框 - Selecting checkboxes using selenium web driver with python Python-Selenium Web驱动程序错误-self._driver.execute-AttributeError:“ unicode”对象没有属性“ id” - Python - Selenium Web Driver error - self._driver.execute - AttributeError: 'unicode' object has no attribute 'id' 使用 Python 和 Selenium Web Driver 每秒刷新网页 3 或 4 次 - Refresh a web page 3 or 4 times a second using Python and Selenium Web Driver 用于Python中Selenium的Firefox Web驱动程序 - Firefox web driver for Selenium in Python Python selenium web驱动程序错误 - Python selenium web driver error Python,网络驱动程序错误(Selenium) - Python, error with web driver (Selenium) 如何使用Selenium Web驱动程序和python单击导航栏? - How to click on navigation bar using selenium web driver with python? 尝试使用Selenium Web驱动程序单击Python中的按钮 - Trying to click a button in Python using Selenium Web Driver 如何使用Selenium Web驱动程序和python作为脚本语言单击图像 - how to click on an image using selenium web driver and python as scripting language 如何在 Z23EEEB4347BDD755BFC6B7EE9A 中使用 selenium firefox 和 chrome 驱动程序翻译 web 页面? - How to translate a web page using selenium firefox and chrome driver in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM