51Testing软件测试论坛

标题: Python selenium error:TypeError: 'module' object is not callable [打印本页]

作者: bluesky_001    时间: 2016-1-14 13:39
标题: Python selenium error:TypeError: 'module' object is not callable
从Selenium IDE里export test case as Python 2/unittest/Remote Control导出python的脚本如下:

# -*- coding: utf-8 -*-
from selenium import selenium
import unittest, time, re
class remote_python_baidu(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*chrome", "https://www.baidu.com/")
        self.selenium.start()
   
    def test_remote_python_baidu(self):
        sel = self.selenium
        sel.open("/")
        sel.click("id=kw")
        sel.type("id=kw", "python")
        sel.click("id=su")
   
    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
    unittest.main()




在Python里执行总报错:
E
======================================================================
ERROR: test_remote_python_baidu (__main__.remote_python_baidu)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\auto_test\remote_python_baidu.py", line 8, in setUp
    self.selenium = selenium("localhost", 4444, "*chrome", "https://www.baidu.com/")
TypeError: 'module' object is not callable
----------------------------------------------------------------------
Ran 1 test in 0.020s
FAILED (errors=1)

请问是什么原因引起的?

作者: 屋落天晴    时间: 2016-1-28 14:58
为什么还有selenium 1.0,用selenium 2.0多好




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2