Firefox+Selenium IDE

1、安装

刚开始在windows上安装,firefox5,selenium1.2。装完之后点击Selenium IDE buttons,总是说You don't have installed Selenium IDE!现在发现原来是selenium1.2版本不支持firefox5引起的。后来今天到公司,看到firefox是18.0,又在add ons那里安装,还是安装selenium1.2版本的,装完还是有一样问题,最后到Selenium IDE的官网上查看,现在selenium已经更新到2点多的版本了,上面也写了那个版本新增了对firefox*的支持,最后现在目前的最新版本Selenium2.2,解决了问题!

Selenium版本更新  Selenium官网下载

2、对于source的format问题

刚开始,以为在format clipboard那里选择source的语言,但是无论我选了什么,source显示的都是HTML语言。在options的format里看到的是 want the formats back?Click to read ....。后来打开options,将Enable experimental features勾上即可!

3、解决下拉框选择问题

http://www.51testing.com/?uid-367166-action-viewspace-itemid-846201

4、脚本整理

#-*-coding=utf-8
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
from selenium.webdriver import ActionChains
class Dingjia(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.base_url = "http://192.168.88.240/"
        self.verificationErrors = []
        self.accept_next_alert = True
    
    def test_dingjia(self):
        driver = self.driver
        driver.get(self.base_url + "/dbackup")
        time.sleep(3)
        handle = driver.window_handles
        driver.switch_to_frame(0)
        driver.find_element_by_id("serialRadio").click()
        driver.find_element_by_id("trialRadio").click()
        driver.find_element_by_xpath("//div[3]/label").click()
        driver.find_element_by_id("continue").click()
        driver.switch_to_window(handle)
        driver.find_element_by_id("UserNameID").send_keys("admin")
        driver.find_element_by_id("PWID").send_keys("admin")
        driver.find_element_by_id("LoginButton").click()
        alert = self.driver.switch_to_alert()
        addFTP(driver,"ftp1831","192.168.88.183","irene","dingjia","183FTP/complicate")
#        alert.accept()
#------------------------------登录进来了-------------------------------------
        def addFTP(driver,name,ip,lname,lpasswd,dir):
            action_chains = ActionChains(driver)
            time.sleep(3)
            action_chains.move_to_element(driver.find_element_by_link_text("存储服务器")).perform()
            action_chains.click(driver.find_element_by_link_text("添加存储服务器")).perform()
            time.sleep(3)
            driver.find_element_by_id("strFTPNameID").send_keys(name)
            se = driver.find_element_by_id("protocalSelect")
            se.find_element_by_xpath("//option[@value='ftp']").click()
            time.sleep(3)
            driver.find_element_by_css_selector("input.input").send_keys(ip)
            driver.find_element_by_id("strFTPLoginNameID").send_keys(lname)
            driver.find_element_by_id("strFTPLoginPWID").send_keys(lpasswd)
            driver.find_element_by_id("nPathID").send_keys(dir)
            driver.find_element_by_id("nRemanentDateNumID").send_keys("1")
            driver.find_element_by_id("Submit").click()
            alert = self.driver.switch_to_alert()
            alert.accept()
#------------------------------添加存储服务器成功--------------------------------
        time.sleep(5)
#------------------------------注册用户------------------------------------------
        def addUser(name,passwd,confirmpasswd,email,telephone):
            action_chains.move_to_element(driver.find_element_by_link_text("用户管理")).perform()
            action_chains.click(driver.find_element_by_link_text("注册用户")).perform()
            driver.find_element_by_id("username").send_keys(name)
            driver.find_element_by_id("password").send_keys(passwd)
            driver.find_element_by_id("confirmpassword").send_keys(confirmpasswd)
            driver.find_element_by_id("email").send_keys(email)
            driver.find_element_by_id("telephone").send_keys(telephone)
        driver.switch_to_frame(0)
        time.sleep(5)
        driver.find_element_by_link_text("监控管理").click()
        driver.switch_to_frame(0)
        time.sleep(5)
        driver.find_element_by_link_text("退出").click()
        time.sleep(5)

if __name__ == "__main__":
    unittest.main()
相关文章
相关标签/搜索