-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyoudao.py
More file actions
25 lines (21 loc) · 814 Bytes
/
youdao.py
File metadata and controls
25 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# coding=utf-8
from selenium import webdriver
import unittest, time
class YoudaoTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.implicitly_wait(30) #隐性等待时间为30秒
self.base_url = "http://www.youdao.com"
def test_youdao(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("translateContent").clear()
driver.find_element_by_id("translateContent").send_keys(u"你好")
driver.find_element_by_id("translateContent").submit()
time.sleep(3)
page_source=driver.page_source
self.assertIn( "hello",page_source)
def tearDown(self):
self.driver.quit()
if __name__ == "__main__":
unittest.main()