Comments (8)
用HTML 运行 以下代码。出现以上bug 。
coding=utf-8
from selenium import webdriver
import unittest
class Test_ranzhi(unittest.TestCase):
url = 'http://laibaoqin.top/ranzhi/www'
user = 'admin'
password = 12345678
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Firefox()
@classmethod
def tearDownClass(cls):
cls.driver.quit()
def test_case1(self):
pass
self.driver.maximize_window()
self.driver.implicitly_wait(30)
self.driver.get(url)
text = self.driver.find_element_by_css_selector(".btn").text
print(text)
if text != "繁體": # 选择系统语言
self.driver.find_element_by_css_selector(".btn").click()
self.driver.find_element_by_xpath("//*[text()='繁體']").click()
self.driver.find_element_by_css_selector("#account").send_keys(user)
self.driver.find_element_by_css_selector("#password").send_keys(password)
self.driver.find_element_by_xpath("//*[@id='keepLoginon']").click()
self.driver.find_element_by_css_selector('#submit').click()
try:
act_name = self.driver.find_elements_by_css_selector(".nav.navbar-nav>li>a")[0].text
print(act_name)
assert act_name == "admin"
except Exception as e:
print("验证出错了", e)
print("11111113")
self.assertEqual(1 ,2)
from htmltestrunner_cn.
python3
from htmltestrunner_cn.
self.driver.find_element_by_css_selector("#account").send_keys(user)
self.driver.find_element_by_css_selector("#password").send_keys(password) 有参数化的 报AttributeError: 'NoneType' object has no attribute 'find' ,请看看 !
from htmltestrunner_cn.
没重现啊,兄弟!你的参数化作用域也不对,下面根本引用不到的,还不如放在class上面
from htmltestrunner_cn.
#-*- coding: utf-8 -*-
from selenium import webdriver
import unittest
import time
url = 'http://laibaoqin.top/ranzhi/www'
user = 'admin'
password = 12345678
class Test_ranzhi(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Firefox()
@classmethod
def tearDownClass(cls):
cls.driver.quit()
def test_case1(self):
"""一个测试用例"""
self.driver.maximize_window()
self.driver.implicitly_wait(5)
self.driver.get(url)
text = self.driver.find_element_by_css_selector(".btn").text
print(text)
if text != "繁體": # 选择系统语言
self.driver.find_element_by_css_selector(".btn").click()
self.driver.find_element_by_xpath("//*[text()='繁體']").click()
self.driver.find_element_by_css_selector("#account").send_keys(user)
self.driver.find_element_by_css_selector("#password").send_keys(password)
self.driver.find_element_by_xpath("//*[@id='keepLoginon']").click()
self.driver.find_element_by_css_selector('#submit').click()
time.sleep(1)
try:
print(self.driver.find_element_by_class_name('bootbox-body').text)
self.driver.find_element_by_xpath('//button[@data-bb-handler="ok"]').click()
except:
pass
try:
act_name = self.driver.find_elements_by_css_selector(".nav.navbar-nav>li>a")[0].text
print(act_name)
assert act_name == "admin"
except Exception as e:
print("验证出错了", e)
print("233")
self.assertEqual(1 ,2)
from htmltestrunner_cn.
from htmltestrunner_cn.
1、在teardownClass 中初始化driver 是不会重启浏览器的,一个测试类只执行一次,要每次测试都重启放在setUp和tearDown中初始化和关闭
2、我这不编写注释也没有问题的,不知道你的问什么返回了None,因为本身用的是TestCase的_testMethodDoc,这块再针对改一下~
from htmltestrunner_cn.
我的python 版本3.6 anaconda装的
from htmltestrunner_cn.
Related Issues (16)
- ConnectionRefusedError: [WinError 10061] because the target machine actively refused, unable to connect. HOT 6
- 通过率计算了跳过的用例 HOT 1
- “饼图”位置固定,信息重叠 HOT 1
- Python3截图问题 HOT 2
- ddt
- appium中ddt模块无法使用
- 增加对多线程执行用例的支持
- html报告统计总数有问题 HOT 3
- 怎么可以使代码里的print的log打印出来 HOT 4
- 下载你的示例,无法生成报告 HOT 1
- 测试详情表单缺少自动换行 HOT 2
- 你好,使用appium,做手机端webview自动化,截图功能不太好用 HOT 3
- 对macaca框架支持吗? HOT 2
- AttributeError: '_ErrorHolder' object has no attribute '_testMethodDoc' HOT 5
- 报告显示异常 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from htmltestrunner_cn.