• j 截图看下你完整的脚本吧, 错误提示说是 line 1 报错, 你截的是 49 行开始

  • 你这里是想写 insert 吗? 多检查一下语句格式吧

  • 怎样实际减轻手工测试,提升效率 : 你可以这么想,如果每次发新版都有 100 条用例需要回归,如果其中 30 条已经通过自动化执行,那么可以减轻你 30% 的工作;如果有多台测试设备需要执行,减轻的工作会更多。

    至于如何封装: 只要是重复的步骤,都可以封装起来给多个用例调用。 例如登录流程,基本上每个用例都可以需要调用的,就不用每个用例都写一遍登录的步骤,封装成公共方法来调用即可,而且方便维护。

  • 昨天大致按 第一种思路写了下面的测试脚本,不过后来发现页面上有些特殊的展示和取到的数据顺序不一样(例如 HK 和 TW 单独列了出来),所以脚本没完全跑通。 仅供参考吧:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    import time
    
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get('https://www.millenniumhotels.com/en/hotels/')
    
    region_list = ["Asia", "Europe", "Middle East", "New Zealand", "United States"]
    
    target_country = [['China', 'Indonesia', 'Japan', 'Malaysia', 'Philippines', 'Singapore', 'Thailand'], ['France', 'Georgia', 'Italy', 'United Kingdom'], ['Iraq', 'Jordan', 'Kuwait', 'Oman', 'Palestine', 'Qatar', 'Saudi Arabia', 'Turkey', 'UAE'], ['New Zealand'], ['United States']]
    target_city = [[['Beijing', 'Chengdu', 'Fuqing', 'Hangzhou', 'Shanghai', 'Wuxi', 'Wuyishan', 'Xiamen', 'Zunyi', 'Hong Kong', 'Taichung', 'Hualien'], ['Jakarta'], ['Tokyo'], ['Cameron Highlands', 'Kuala Lumpur', 'Penang'], ['Manila'], [], ['Phuket']], [['Paris'], ['Tbilisi'], ['Rome'], ['Aberdeen', 'Birmingham', 'Cardiff', 'Dudley', 'Gatwick', 'Glasgow', 'Liverpool', 'London', 'Manchester', 'Newcastle', 'Plymouth', 'Reading', 'Sheffield', 'Slough']], [['Sulaimani'], ['Amman'], ['Al Jahra', 'Kuwait City'], ['Muscat', 'Mussanah', 'Salalah'], ['Ramallah'], ['Doha'], ['Hail', 'Madinah', 'Makkah', 'Riyadh'], ['Istanbul'], ['Abu Dhabi', 'Dubai', 'Sharjah']], [['Auckland', 'Bay of Islands', 'Dunedin', 'Greymouth', 'Hokianga', 'New Plymouth', 'Palmerston North', 'Queenstown', 'Rotorua', 'Taupo', 'Te Anau', 'Wairarapa', 'Wanganui', 'Wellington']], [['Anchorage', 'Boston', 'Boulder', 'Buffalo', 'Chicago', 'Cincinnati', 'Durham', 'Los Angeles', 'Minneapolis', 'Nashville', 'New York', 'Scottsdale']]]
    target_hotel = [[[['Grand Millennium Beijing', 'Millennium Residences @ Beijing Fortune Plaza'], ['Millennium Hotel Chengdu'], ['Millennium Hotel Fuqing'], ['Millennium Resort Hangzhou'], ['New World Millennium Hong Kong Hotel'], ['Millennium Gaea Resort Hualien'], ['Grand Millennium Shanghai HongQiao'], ['Millennium Hotel Taichung'], ['Millennium Hotel Wuxi'], ['Millennium Resort Wuyishan'], ['Millennium Harbourview Hotel Xiamen'], ['Millennium Hotel Zunyi']], [['Millennium Hotel Sirih Jakarta']], [['Millennium Mitsui Garden Hotel Tokyo']], [['Copthorne Hotel Cameron Highlands'], ['Grand Millennium Kuala Lumpur'], ['Copthorne Orchid Hotel Penang']], [['The Heritage Hotel Manila']], [], [['Millennium Resort Patong Phuket']]], [[['Millennium Hotel Paris Charles De Gaulle', 'Millennium Hotel Paris Opera']], [['The Biltmore Hotel Tbilisi']], [['Grand Hotel Palace Rome']], [['Copthorne Hotel Aberdeen'], ['Copthorne Hotel Birmingham'], ['Copthorne Hotel Cardiff-Caerdydd'], ['Copthorne Hotel Merry Hill-Dudley'], ['Copthorne Hotel Effingham Gatwick', 'Copthorne Hotel London Gatwick'], ['Millennium Hotel Glasgow'], ['Hard Days Night Hotel Liverpool'], ['Copthorne Tara Hotel London Kensington', 'Millennium and Copthorne Hotels at Chelsea Football Club', 'Millennium Gloucester Hotel London Kensington', 'Millennium Hotel London Knightsbridge', "The Bailey's Hotel London", 'The Chelsea Harbour Hotel'], ['Copthorne Hotel Manchester'], ['Copthorne Hotel Newcastle'], ['Copthorne Hotel Plymouth'], ['Millennium Madejski Hotel Reading'], ['Copthorne Hotel Sheffield'], ['Copthorne Hotel Slough-Windsor']]], [[['Copthorne Hotel Baranan', 'Grand Millennium Hotel Sulaimani', 'Millennium Kurdistan Hotel and Spa']], [['Grand Millennium Amman']], [['Copthorne Al Jahra Hotel & Resort'], ['Copthorne Kuwait City', 'Millennium Hotel and Convention Centre Kuwait']], [['Grand Millennium Muscat', 'Millennium Executive Apartments Muscat'], ['Millennium Resort Mussanah'], ['Millennium Resort Salalah']], [['Millennium Palestine Ramallah']], [['Copthorne Hotel Doha', 'Kingsgate Hotel Doha', 'Millennium Hotel Doha', 'Millennium Plaza Doha']], [['Millennium Hail Hotel Saudi Arabia'], ['Millennium Al Aqeeq Hotel', 'Millennium Madinah Airport', 'Millennium Taiba Hotel'], ['Copthorne Makkah Al Naseem', 'M Hotel Makkah by Millennium', 'Makkah Millennium Hotel', 'Makkah Millennium Towers', 'Millennium Makkah Al Naseem'], ['Copthorne Hotel Riyadh']], [['Millennium Istanbul Golden Horn']], [['Bab Al Qasr Hotel', 'Grand Millennium Al Wahda', 'Kingsgate Hotel Abu Dhabi by Millennium'], ['Copthorne Hotel Dubai', 'Grand Millennium Business Bay', 'Grand Millennium Dubai', 'M Hotel Downtown by Millennium', 'Millennium Airport Hotel Dubai', 'Millennium Al Barsha', 'Millennium Atria Business Bay', 'Millennium Place Marina', 'Millennium Plaza Hotel Dubai', 'Studio M Arabian Plaza'], ['Copthorne Hotel Sharjah']]], [[['Copthorne Hotel Auckland City', 'Grand Millennium Auckland', 'M Social Auckland'], ['Copthorne Hotel and Resort Bay of Islands', 'Kingsgate Hotel Autolodge Paihia'], ['Kingsgate Hotel Dunedin'], ['Kingsgate Hotel Greymouth'], ['Copthorne Hotel and Resort Hokianga'], ['Copthorne Hotel Grand Central New Plymouth', 'Millennium Hotel New Plymouth Waterfront'], ['Copthorne Hotel Palmerston North'], ['Copthorne Hotel & Apartments Queenstown Lakeview', 'Copthorne Hotel and Resort Queenstown Lakefront ', 'Millennium Hotel Queenstown'], ['Copthorne Hotel Rotorua', 'Millennium Hotel Rotorua'], ['Millennium Hotel and Resort Manuels Taupo'], ['Kingsgate Hotel Te Anau'], ['Copthorne Hotel & Resort Solway Park Wairarapa'], ['Kingsgate Hotel The Avenue Wanganui'], ['Copthorne Hotel Wellington Oriental Bay']]], [[['The Lakefront Anchorage'], ['The Bostonian Boston'], ['Millennium Harvest House Boulder'], ['Millennium Buffalo'], ['Millennium Knickerbocker Chicago'], ['Millennium Cincinnati'], ['Millennium Durham'], ['Millennium Biltmore Los Angeles'], ['Millennium Minneapolis'], ['Millennium Maxwell House Nashville'], ['Millennium Broadway New York Times Square', 'Millennium Premier New York Times Square'], ['The McCormick Scottsdale']]]]
    
    
    for i in range(len(region_list)):
        print('region is : %s' %region_list[i])
        driver.find_element_by_link_text(region_list[i]).click()
        time.sleep(5)
        # 获取城市列表
        country_list = driver.find_elements(by=By.CLASS_NAME, value='nk2-waterfall-country')
        print('country lenth: %d' % len(country_list))
        assert len(country_list)==len(target_country[i])
        for j in range(len(country_list)):
            country_name = country_list[j].find_element(by=By.CLASS_NAME, value='nk2-waterfall-country-name').text
            print('country name is : %s' %country_name)
            assert country_name==target_country[i][j]
    
            # 获取城市列表
            city_list = country_list[j].find_elements(by=By.CLASS_NAME,value='nk2-waterfall-city')
            print('city lenth: %d' %len(city_list))
            assert len(city_list) == len(target_city[i][j])
            if len(city_list):
                for k in range(len(city_list)):
                    city_name = city_list[k].find_element(by=By.CLASS_NAME,value='nk2-waterfall-city-name').text
                    print('city name is : %s' %city_name)
                    assert city_name==target_city[i][j][k]
    
                    hotel_list = city_list[k].find_elements(by=By.CLASS_NAME,value='nk2-waterfall-hotel-name')
                    print('hotel lenth in city %s : %d' %(city_name,len(hotel_list)))
                    assert len(hotel_list)==len(target_hotel[i][j][k])
                    for l in range(len(hotel_list)):
                        print(hotel_list[l].text)
                        assert hotel_list[l].text==target_hotel[i][j][k][l]
            else:
                hotel_list = country_list[j].find_elements(by=By.CLASS_NAME, value='nk2-waterfall-hotel-name')
                print('hotel lenth in country %s : %d' % (country_name, len(hotel_list)))
                assert len(hotel_list) == len(target_hotel[i][j][k])
                for l in range(len(hotel_list)):
                    print(hotel_list[l].text)
                    assert hotel_list[l].text == target_hotel[i][j][k][l]
    
    driver.quit()
    
    
  • 1 楼给出的接口验证方式是一种思路,可以做一下接口层面的验证。不过我觉得有两个问题:

    • 后台接口和前端展示的功能是分开的,所以接口数据没问题,不代表前端的展示也没问题。
    • 还需要验证接口数据是否完全一致,所以需要拿到一份完整的标准数据列表,然后拿接口返回数据解析后和标准数据列表进行对比验证。

    如果从 UI 的角度测试,建议思路有以下几种:

    • 同样拿到标准数据列表,然后在当前页面查找是否每个数据是否一致。完整的解决方案,需要 region-country-city - hotel 四级的数据都一致,才能既保证酒店都列出来了,也能保证数据的层级和顺序展示正确。
    • 另一种思路是通过截图,然后进行图像对比。如果两张图片的重合率达到标准(例如 99%),则基本能说明展示的数据是一致的。之前看到论坛里有类似的图片对比解决方案,可以查一下。
  • 可能是根据请求头里的的浏览器信息判断的

  • 关键字驱动?

  • 看你选的节点 ,还以为你要问怎么学 python

  • 逹先生 2018年 度总结 at 2019年03月13日

    7 月份预产期了还这么安心计划出远门😂

  • 没有接触过长连接类型的这种情况,不过猜测除了返回正常的数据外,应该有个时间戳代表当前时间。 验证点除了数据格式外,时间延迟也是一个点,数据正确性就要想办法验证了(关键看具体的实现逻辑是怎么样,如果是实时查数据库,一种思路是先造数据插到数据库,然后验证返回的数据是否与期望的相同)

  • 1 秒刷新一次,是客户端的行为吗? 1 秒发起一次查询?

    还是说是长连接,服务端 1 秒发一次数据回来?

  • 和一般的接口有什么差别吗?

  • 同一份工作坚持几十年? 首先你确定这家公司能坚持几十年吗?

  • 想问下对于持续集成这块是怎么处理的?

  • 看一下 runalltest.py 文件的内容

  • 微信小程序 bug at 2019年02月28日

    这是小游戏吧?

  • while i>=49:
          id=str(i+1)
    while beginID>=666:
          thirdParkId=str(beginID+i)
    

    另外看不懂这两段 while 的作用, 如果 i 和 beginID 满足条件,是会死循环跳不出去的吧? 感觉上你是不是想用 if ?

  • 你的自动化测试用例是用来干嘛的? 如果是直接用来给机器执行的,就按代码设定的格式来写,不然读取不了吧?

    格式一不一样,取决于你们的设计。

  • count = 10  # 1万
        beginID = 666
        try:
            with open("/Users/zln/user.txt", "wb") as fo:
                length = count + 1
                for i in range(49, length):
    

    这里的逻辑有问题吧? length = 10+1 ,也就是 11; 然后 for i in range(49,11) 没有满足条件的 i ,所以进不去这个循环。

  • 你的文件名不应该和模块名重复,否则导入的时候会找不到

    jenkins.py 这个文件不要和已存在的模块 jenkins 重名

  • 为啥要在环境 hosts 里面配? 写在代码里或者做成配置项不行吗?

  • 😂 好吧,我就觉得这个问题太奇怪了

  • 刚刚尝试添加了一个元素不存在时的报错处理,可以更新代码后再跑一下看看日志

  • 我这边是正常可以跑的。 麻烦检查一下你的 selenium 版本,或者看下错误的截图有没有什么问题?

  • 内部使用有集成的,不过效果不是很好,后来改成单独的接口测试项目进行管理了