selenium webdriver Pythonシリーズの文章に基づいていくつかのテストシーンを追加します
1535 ワード
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import os
import sys
from selenium import webdriver
cur_dir = os.getcwd()
sys.path.append(cur_dir.split(r'\test_case')[0])
from public import login
# from selenium.webdriver.common.keys import Keys
import time
class TestDel(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://www.126.com/"
self.verificationErrors = []
self.accept_next_alert = True
#
def test_del_mail(self):
driver = self.driver
driver.get(self.base_url)
#
login.login(self, 'xxxx', 'xxxx')
#
driver.find_element_by_class_name('nui-tree-item-text').click()
time.sleep(2)
driver.find_elements_by_xpath("//span[@class='nui-chk-symbol']/b").pop(1).click()
try:
spans = driver.find_elements_by_tag_name('span')
for s in spans:
if s.text == u' ':
s.click()
except:
pass
#
text = driver.find_element_by_css_selector("span.nui-tips-text>a").text
self.assertEqual(text, u' ')
#
login.logout(self)
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()