python+selenium,能启动浏览器,但运行不了,求大神指导
#!/usr/bin/env python3#coding=utf-8
import sys,time,re
import unittest,HTMLTestRunner #引入unittest框架包
from os.path import abspath,dirname,join
from selenium import webdriver
from getopt import getopt
class Suit(unittest.TestCase):
@classmethod
def setUpClass(self):
self.verificationErrors = []
driver = 'chrome'
opts, args = getopt(sys.argv,'b:n:')
for o, a in opts:
if o == '-b':
driver = a
if driver == 'ie':
browser = webdriver.Ie()
elif driver == 'chrome':
browser = webdriver.Chrome()
elif driver =='firefox':
browser = webdriver.Firefox()
elif driver =='PhantomJS':
browser = webdriver.PhantomJS()
browser.maximize_window()
else:
assert False,'Unknown driver'
return browser
def suite():
moduleNames = [
#登录
'test2',
]
modules = map(__import__,moduleNames)
suite = unittest.TestSuite()
for module in modules:
suite.addTest(module.suite(g_browser))
return suite
if __name__ == '__main__':
g_browser = Suit.setUpClass()
timestr = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
filename = "D:\\worktest\\result\\result_" + timestr + ".html"
print (filename)
fp = open(filename,'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream=fp,
title='测试结果',
description='测试报告'
)
runner.run(suite())
g_browser.quit()
#!usr/bin/env python3
#coding=utf-8
import sys,time,re
import unittest,HTMLTestRunner
from os.path import abspath,dirname,join
from getopt import getopt
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from Ext import *
from sext import *
from datetime import *
import time
class LoginCase(unittest.TestCase):
def testlogin(self):
g_browser.get("http://pan.baidu.com/")
time.sleep(2)
g_browser.find_element_by_xpath("//div/a").click()
time.sleep(2)
def suite(browser):
global g_browser
g_browser = browser
global Ext
Ext=Ext(g_browser)
suite=unittest.TestSuite()
suite.addTest(LoginCase("testlogin"))
return suite
if __name__ == '__main__':
unittest.main()
运行提示 运行错误提示 这不是很明显吗,你没有sext这个模块,这么引入???没有就用pip install,其实我也没有见过这个模块。。。 cq520131517 发表于 2017-5-3 15:32
这不是很明显吗,你没有sext这个模块,这么引入???没有就用pip install,其实我也没有见过这个模块。。 ...
但是提示导不进去:dizzy: sunkkkk 发表于 2017-5-3 15:43
但是提示导不进去
这提示不是导不进,而是没有找到sext这个模块。 百度搜不到sext这个模块,不知道你怎么来的,是不是写错了
页:
[1]