日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Selenium學(xué)習(xí)筆記(一)-創(chuàng)新互聯(lián)
不過多的介紹Selenium的歷史以及應(yīng)該使用哪個版本進(jìn)行測試了。這只是我的學(xué)習(xí)筆記,方便以后回顧新的知識。Selenium學(xué)習(xí)筆記(一)

Selenium的命令—Selenese

Selenese---Selenium提供的可以進(jìn)行全面的Web應(yīng)用測試的命令的總稱??梢酝ㄟ^http://release.seleniumhq.org/selenium-core/1.0.1/reference.html 查詢。

成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供桑珠孜網(wǎng)站建設(shè)、桑珠孜做網(wǎng)站、桑珠孜網(wǎng)站設(shè)計、桑珠孜網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、桑珠孜企業(yè)網(wǎng)站模板建站服務(wù),十年桑珠孜做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

該命令主要有三種子類型,Actions、Accessors和 Assertions:

  1. 1. Actions決定Selenium工具怎樣操作Web系統(tǒng),如:點擊某個鏈接和選擇某個下拉選項,若一個Action執(zhí)行失敗或發(fā)生錯誤,當(dāng)前測試被終止執(zhí)行。
  2. 2. Accessors檢查當(dāng)前系統(tǒng)狀態(tài),并將結(jié)果存放在變量中。如: storeTitle 命令。它們也被用來自動產(chǎn)生斷言
  3. 3. Assertions類似于Accessors,不過它們驗證系統(tǒng)是否遵從于期望的表現(xiàn)。如:保持頁面標(biāo)題是…、驗證多選框…被選中。
  4. Selenium Assertions 可以被歸納為三種模式: “assert”, “verify“,”waitFor“。
  5. assert失敗,測試終止,verify失敗,測試?yán)^續(xù)進(jìn)行,并在日志中記錄失敗。通常使用assert確保測試在正確的頁面上進(jìn)行,使用verify驗證表單數(shù)據(jù),頁簽等。
  6. waitFor等待某些條件變真(在對Ajax類應(yīng)用中特別管用),當(dāng)條件為真時,它將立刻成功,在預(yù)設(shè)時間內(nèi)(setTimeout)條件沒有變成真,它將失敗并停止測試執(zhí)行?!?/li>

附上測試gmail登錄的腳本。應(yīng)該可以精簡許多,明天在研究了。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re

class Test(unittest.TestCase):
def setUp(self):
        self.driver= webdriver.Firefox()
        self.driver.implicitly_wait(30)
        self.base_url= "https://accounts.google.com"
        self.verificationErrors= []
        self.accept_next_alert= True
    
def test_(self):
        driver= self.driver
        driver.get(self.base_url+ "/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2")
# ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]   # ERROR: Caught exception [Error: locator strategy either id or name must be specified explicitly.]        driver.find_element_by_id("Email").send_keys("******")
        driver.find_element_by_id("Passwd").send_keys("******")
        driver.find_element_by_id("signIn").click()
# Warning: assertTextPresent may require manual changes   #self.assertRegexpMatches(driver.find_element_by_css_selector("BODY").text, r"^[sS]*Gmail[sS]*$")    
  def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True
    
def close_alert_and_get_its_text(self):
try:
            alert= self.driver.switch_to_alert()
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()

文章名稱:Selenium學(xué)習(xí)筆記(一)-創(chuàng)新互聯(lián)
網(wǎng)頁地址:http://www.dlmjj.cn/article/dspjhc.html