Chinaunix

标题: python+selenium' object has no attribute 'getValue [打印本页]

作者: wsywfw3    时间: 2011-08-29 16:33
标题: python+selenium' object has no attribute 'getValue
这一个测试用例,判断有没有登录成功, self.assertEqual(sel.getValue("xpath=//*[@id='settings-email-address']"), self.verificationErrors),提示错误
selenium' object has no attribute 'getValue  
求解答


# coding=gbk
from selenium import selenium
import unittest, time, re


class NewTest(unittest.TestCase):
   
    def setUp(self):
        self.verificationErrors = ["xxxxx@163.com"]
        self.selenium = selenium("localhost", 4444, "*chrome", "http://xxxxxx.com/")
        self.selenium.start()
   
    def test_denglu(self):
        sel = self.selenium
        sel.open("/account/login.php")
        sel.click(u"link=登录")
        sel.wait_for_page_to_load("30000")
        sel.type("login-email-address", "xxxxx@163.com")
        sel.type("login-password", "111111")
        sel.click("login-submit")
        sel.wait_for_page_to_load("30000")
        sel.click("myaccount")
        sel.wait_for_page_to_load("30000")
        sel.click("//div[@id='dashboard']/ul/li[6]/a")
        /html/body/div/div[3]/div[6]/div/div/div/ul/li[7]/a
        sel.wait_for_page_to_load("30000")
        self.assertEqual(sel.getValue("xpath=//*[@id='settings-email-address']"), self.verificationErrors)

   
   
    def tearDown(self):
        self.selenium.stop()
#        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()
作者: ubuntu_mark    时间: 2011-08-29 17:10
没试过这个工具,那这个object对象有没有这个用法呢,还是对象或字符串错误?
作者: wsywfw3    时间: 2011-08-29 17:15
回复 2# ubuntu_mark


    有的哇!
作者: renxiao2003    时间: 2011-08-29 22:02
我都是用记事本。
作者: wsywfw3    时间: 2011-08-31 14:11
ok 了 原来是 sel.get_value 而不是sel.getValue
作者: ubuntu_mark    时间: 2011-08-31 19:38
还是自己疏忽,现在在学习web开发,也经常出现这样的错误,需要细心点,总结出来此类错误,要么是没有此方法,要嘛是值或者对象错误




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2