TA的每日心情 | 开心 2019-12-24 17:28 |
---|
签到天数: 9 天 连续签到: 1 天 [LV.3]测试连长
|
定位没报错
按照你说的,也不行
定位到元素,用mouse_move那一句报错了
代码:
#coding:utf-8
import time
import unittest
import os
import SendKeys
from selenium import webdriver
from common.select_people import Select_People
from common.login_oa import Login_Oa
from selenium.common.exceptions import NoSuchAttributeException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
class Send_Email(unittest.TestCase):
@classmethod
def setUpClass(cls):
url = "*********************"
cls.driver=webdriver.Chrome()
cls.driver.get(url)
time.sleep(3)
Login_Oa(cls.driver).login('wanglp','itouch123')
time.sleep(3)
def test_send(self):
self.driver.find_element_by_id('50018').click()
time.sleep(3)
self.driver.find_element_by_css_selector("#Js_sidebarBd>ul>li:nth-child(1)>a").click()
self.driver.switch_to.frame('js_iframe')
self.driver.find_element_by_id('btnWriteMail').click()
time.sleep(3)
self.driver.find_element_by_id('btnSelectUser').click()
time.sleep(3)
all_h=self.driver.window_handles
Select_People(self.driver).select(all_h[1],u'吴进',all_h[0])
time.sleep(3)
self.driver.switch_to.frame('js_iframe')
self.driver.find_element_by_id('MainPlaceHolder_txtSubject').send_keys(u'请假申请')
time.sleep(3)
ele=self.driver.find_elements_by_id('SWFUpload_0')
ActionChains(self.driver).move_to_element(ele).perform()
ele.send_Keys(Keys.ENTER)
self.driver.switch_to.frame('baidu_editor_0')
self.driver.find_element_by_xpath('/html/body').send_keys(u'个人私事,请假一天,请领导批准!')
self.driver.switch_to.default_content()
self.driver.switch_to.frame('js_iframe')
self.driver.find_element_by_id('MainPlaceHolder_btnSend').click()
time.sleep(3)
msg=self.driver.find_element_by_class_name('alert-success').text
self.assertEqual(msg,u'温馨提示:您的邮件已发送“吴进,...”。')
@classmethod
def tearDownClass(cls):
cls.driver.quit()
错误信息:
Error
Traceback (most recent call last):
File "C:\Python27\lib\unittest\case.py", line 329, in run
testMethod()
File "C:\Documents and Settings\Administrator\PycharmProjects\OA\test_case\email\test_send_email.py", line 38, in test_send
ActionChains(self.driver).move_to_element(ele).perform()
File "C:\Python27\lib\site-packages\selenium\webdriver\common\action_chains.py", line 74, in perform
action()
File "C:\Python27\lib\site-packages\selenium\webdriver\common\action_chains.py", line 225, in <lambda>
Command.MOVE_TO, {'element': to_element.id}))
AttributeError: 'list' object has no attribute 'id'
|
|