1.本がtest_loginqq.pyのコードされていない。'my_test' オブジェクトが属性 'find_element_by_xpath'
#coding=utf-8
from selenium import webdriver
import time
class loginout():
def test_login(self,driver):
driver = webdriver.Firefox()
driver.get("https://en.mail.qq.com/cgi-bin/loginpage")
driver.implicitly_wait(30)
driver.switch_to_frame("login_frame")
driver.find_element_by_id("switcher_plogin").click()
driver.find_element_by_id("u").clear()
driver.find_element_by_id("u").send_keys("*****")
#driver.find_element_by_id("emailTips_0").click()
driver.find_element_by_id("p").clear()
driver.find_element_by_id("p").send_keys("****")
driver.find_element_by_id("login_button").click()
title=driver.title
print (title)
driver.implicitly_wait(30)
user=driver.find_element_by_id("useraddr").text
print user
print "log in successfully"
#driver.quit()
def test_logout(self,driver):
#driver.implicitly_wait(30)
driver.find_element_by_xpath("//a[test()='Sign out']").click()
title=driver.title
print title
driver.quit()
2.このはtest_main.pyのコードである:
#coding=utf-8
from selenium import webdriver
from test_loginqq import loginout
import time
import unittest
class my_test(unittest.TestCase):
def setUp(self):
print "test start"
def test_test(self):
loginout().test_login(self)
loginout().test_logout(self)
def test_test0(self):
a="hello"
b="hello world"
self.assertIn(a,b,msg='a is not in b')
def tearDown(self):
print "test end"
if __name__=='__main__':
suite=unittest.TestLoader().loadTestsFromTestCase(my_test)
unittest.TextTestRunner(verbosity=2).run(suite)
3 。私がtest_main.pyを実行すると、 'my_test'オブジェクトに 'find_element_by_xpath'属性がありません。これについてはわかりません。誰かが私の質問に私を助けることができますか?
私は "私のスクリプトを記録するために、セレンIDEを使用サインアウト "、私はエラーが発生しました:キャッチ例外[エラー:サポートされていないコマンド[selectWindow | null | ]]。 ...これが助けてくれることを願っています –