Selenese---Selenium提供的可以進(jìn)行全面的Web應(yīng)用測(cè)試的命令的總稱??梢酝ㄟ^(guò)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è)計(jì)、桑珠孜網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、桑珠孜企業(yè)網(wǎng)站模板建站服務(wù),十年桑珠孜做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。該命令主要有三種子類型,Actions、Accessors和 Assertions:
附上測(cè)試gmail登錄的腳本。應(yīng)該可以精簡(jiǎn)許多,明天在研究了。
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()