TA的每日心情 | 开心 2017-2-23 09:15 |
---|
签到天数: 13 天 连续签到: 1 天 [LV.3]测试连长
|
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class test (unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://test.robotscloud.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("email").send_keys("15889369825@163.com")
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("qwe123")
driver.find_element_by_id("check").clear()
driver.find_element_by_id("check").send_keys("8798")
driver.find_element_by_id("submit").click()
driver.find_element_by_link_text(u"消息管理").click()
driver.find_element_by_link_text(u"我的工单").click()
driver.find_element_by_id("addOrder").click()
driver.find_element_by_xpath("//div[@id='systemUserModal']/div/div/div[2]/form/div/div/div[2]/span").click()
driver.find_element_by_xpath("//div[@id='systemUserModal']/div/div/div[2]/form/div/div/div[3]/div/ul/li[2]").click()
driver.find_element_by_id("order_theme").clear()
driver.find_element_by_id("order_theme").send_keys("wwwww")
driver.find_element_by_id("detail").clear()
driver.find_element_by_id("detail").send_keys("什么问题")
driver.find_element_by_css_selector("div.form-group.button-group > button.btn.btn-blue").click()
driver.find_element_by_link_text("wwwww").click()
driver.find_element_by_css_selector("textarea").clear()
driver.get(self.base_url + "/adminlogin")
driver.find_element_by_id("email").send_keys("2@163.com")
driver.find_element_by_id("password").clear()
driver.find_element_by_id("password").send_keys("123456")
driver.find_element_by_id("submit").click()
driver.find_element_by_link_text(u"消息管理").click()
driver.find_element_by_link_text(u"平台工单").click()
driver.find_element_by_link_text("wwwww").click()
driver.find_element_by_css_selector("textarea").clear()
driver.find_element_by_css_selector("textarea").send_keys("shenma")
driver.find_element_by_id("handleClick").click()
driver.find_element_by_css_selector("textarea").clear()
driver.find_element_by_css_selector("textarea").send_keys(u"问哦怎么不知道222222222222222222222222222+222222222222222222222222222222222222222222eweee威威的评价去iiqjuqifnhquf!@#¥#¥%……&*()——+}|“|:515《KNJVBGHCXDFZRREYZWAZWVBJ:NKJ:I{O/是的cdc地方vvvwfvwrfwrwr33231d21fdvfveqfrtghnhjmj,看,。l。/;/?‘【}、】’ikbffvedergerqw4165456412814s5qas1qwd151dqiweojeiwjfn我去额窦蛾大奖哦是间谍你发我的那位妇女物品那位妇女我的为您服务呢发我怕你;我们的女生吵架呢无icfndecnweucnfeun")
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
这个每次运行到driver.find_element_by_link_text("wwwww").click()这就会报错,原因页面上有两个“wwww”脚本不知道调用那个,现在想以后运行脚本时第一个driver.find_element_by_link_text("wwwww").click()自动循环让它不要冲突,后面两个直接调用它,这个需要怎么做,最好能帮我修改下,刚学很多都不懂 |
|