zoukankan      html  css  js  c++  java
  • 自动化测试有感

    1、   研究自动化测试也有一段时间了,从不熟悉到慢慢的了解,从不会到会,从迷茫到清晰......

    前段时间一直都很疑惑,为什么要自动化,自动化能给我们带来哪些好处?它存在的价值在哪里?运行一个脚本,执行的时候,难道还要盯着电脑屏幕去关注脚本运行的情况吗?那还不如手动的去点击呢?

    迷茫疑惑的时候,建立多看看一些关于自动化测试的书籍,看看别人项目采用自动化测试,自动化测试给公司创造的价值;

    比如:敏捷测试(里面有几章是说自动化测试的)

    自动化测试指南:

    其他自动测试工具:

    ........

     2、从事测试行业也快一年了,说长不长,说短也不短,可是自己规划自己的职业方向的时候,感觉很迷茫?不知自己以后的方向到底是咋样的?自己是否真正的喜爱测试这个行业?还是当初为了生存才进入这个行业的?其实这跟我大学时的目标或者说理想有偏离了很多;进入测试行业之后,我开始了解功能测试,学习编写测试用例的方法,学习自动化工具,学习JavaScript.....自己有时会很怀疑这是否就是自己想要的生活;

    以下Share下最近写的测试脚本吧:

    def nessouring():   
        chromedriver="D:Program Files (x86)Chromechromedriver.exe"
        os.environ["webdriver.chrome.driver"] = chromedriver
        browser = webdriver.Chrome(chromedriver) # Get local session of firefox
        browser.maximize_window()
        browser.get("http://192.168.1.20:9999") # Load page
        assert "login" in browser.title
        browser.implicitly_wait(2)
        Means.login(browser, '4@pc.com', '123456') #登录pm
        time.sleep(1)# Let the page load, will be added to the API
        browser.find_element_by_xpath("//div[@class='pm tile double icon bg-color-redCustorm']/div/img").click()    #using xpath to find element
        time.sleep(2)
        browser.find_element_by_xpath("//ul[@id='menu']/li/a").click()#click sourcing
        time.sleep(1)
        browser.find_element_by_id("btnSearchNew").click()
        r=random.randint(1,1000)
        print r
        browser.find_element_by_id("LegalName").send_keys(r)
        browser.find_element_by_xpath("//div[@id='entityType']/div").click()
        time.sleep(2)
        entitytype=browser.find_element_by_xpath("//div[@id='entityType']/div[2]/ul/li[3]")
        print "输出entitytype:%s" %(entitytype.text)
        entitytype.click()   #drop list chosen
        time.sleep(2)
        browser.find_element_by_xpath("//div[@id='stateRegistered']/div").click()
        time.sleep(2)
        statere=browser.find_element_by_xpath("//div[@id='stateRegistered']/div[2]/ul/li[7]")
        statere.click()        
        browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").send_keys("129")
        browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").send_keys("619")
        browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").send_keys("1881")
        browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").send_keys("545")
        browser.find_element_by_xpath("//input[@id='ContactOfficeCentralOfficeCode']").send_keys("798")
        browser.find_element_by_xpath("//input[@id='ContactOfficeStationCode']").send_keys("3363")
        
        browser.find_element_by_id("SearchButton").click()
        if r==850 and entitytype.text=='Corporation' and statere.text=='California(CA)':
            alerts=browser.find_element_by_id("alertSearch")
            print "alert的提示信息是否为:This affiliate already exists in the system ! --- %s" %(alerts.text)
            browser.find_element_by_id("LegalName").send_keys('Simpleok!')
            time.sleep(1)
            browser.find_element_by_id("SearchButton").click()
            time.sleep(1)
        else:
            newbutton=browser.find_element_by_id("NewLeadButton")
            if newbutton.is_displayed():
               print "newbutton显示出来了,直接点击按钮New Lead即可!"
               time.sleep(1)
               browser.find_element_by_id("NewLeadButton").click()
            else:
               print"存在相同的phone #或者是office #,需重新填写phone # 或者Office #,需重新填写;"
               browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").clear()
               time.sleep(1)
               browser.find_element_by_xpath("//input[@id='OfficePhoneAreaCode']").send_keys('829')
               browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").clear()
               browser.find_element_by_xpath("//input[@id='OfficePhoneCentralOfficeCode']").send_keys("739")
               browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").clear()
               browser.find_element_by_xpath("//input[@id='OfficePhoneStationCode']").send_keys("1584")
               browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").clear()
               browser.find_element_by_xpath("//input[@id='ContactOfficeAreaCode']").send_keys("981")
               browser.find_element_by_id("SearchButton").click()
               time.sleep(1)
               browser.find_element_by_id("NewLeadButton").click()
        time.sleep(1)   
        print "检查当前页面的URL:http://192.168.1.20:9999/affiliate/pm/sourcing_detail.html ! ---%s" %(browser.current_url)
        browser.find_element_by_xpath("html/body/form/div[1]/div[1]/button[1]").click()
        save_alert=browser.find_element_by_xpath("html/body/div[1]")
        if save_alert.is_displayed():
            print"save_alert被显示了!显示内容为:Please fill out all mandatory fields!f --- %s "%(save_alert.text)
        else:
            print"save_alert没有显示!! <此处有BUG>"
        time.sleep(1)
    

     3、我是一个像空气一样自由的人,妨碍我心灵自由的时候,绝不妥协。轰轰烈烈的恋爱,舍命的读书.

  • 相关阅读:
    Docker Private Registry
    Dockerfile
    docker存储卷
    392. 判断子序列
    1576. 替换所有的问号
    270. 最接近的二叉搜索树值
    292. Nim 游戏
    680. 验证回文字符串 Ⅱ
    876. 链表的中间结点
    543. 二叉树的直径
  • 原文地址:https://www.cnblogs.com/tyen0921/p/3556245.html
Copyright © 2011-2022 走看看