0

问题描述

我都fa方法中,最里面的第三个for循环,如果把循环中的if table.text=='资产业务查询'开始到 Chrome_Drive.find_element_by_xpath("//*[@id='btnClearQuery']/a").click()这一段注释了就可以循环,加上就无法循环了,里面的各种测试语句都可以顺利执行,但是加上就是无法循环,这是什么原因?

问题出现的环境背景及自己尝试过哪些方法

目前百度没有搜到问题,也不报相关错误,就是无法循环,第一个if语句执行完了就结束了

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

fa业务域

def fa():

#进入固定资产管理
Chrome_Drive.find_element_by_id("6C8B27A16FA246D69780EE638FBB3D6A").click()
time.sleep(1)
fa_lists=Chrome_Drive.find_element_by_xpath("//*[@id='6C8B27A16FA246D69780EE638FBB3D6A']").find_elements_by_class_name('category-Name')
#综合查询部分
for fa_model in fa_lists:
    fa_model.click()
    time.sleep(1)
    a_buttons=Chrome_Drive.find_element_by_class_name("appList").find_elements_by_tag_name("a")
    for a in a_buttons:
        a.click()
        time.sleep(1)
        Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
        time.sleep(1)
        tables_sheet=Chrome_Drive.find_element_by_id("app-nav").find_element_by_tag_name("ul").find_elements_by_tag_name("li")

        # table依次测试顺序为:综合查询、资产基础管理、资产业务查询、资产盘点管理
        for table in tables_sheet:
            table.click()
            time.sleep(1)
            Chrome_Drive.switch_to_frame("mainFrame")
            Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
            time.sleep(1)
            print(table.text)

            #测试项目
            if table.text=='资产业务查询':
                time.sleep(1)
                Chrome_Drive.switch_to_frame("mainFrame")
                time.sleep(1)
                
                #搜索框测试
                orderNumber=Chrome_Drive.find_element_by_xpath("//*[@id='list']/tbody/tr[1]/td[3]/a").text
                print(orderNumber)
                Chrome_Drive.find_element_by_css_selector("[name='keySearch']").send_keys(orderNumber)
                time.sleep(1)
                Chrome_Drive.find_element_by_class_name("click_input_icon").click()
                time.sleep(1)
                Chrome_Drive.find_element_by_xpath("//*[@id='list']/tbody/tr[1]/td[3]/a").click()
                time.sleep(1)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[2])
                Chrome_Drive.find_element_by_xpath("//*[@id='closeWindow']/a/span").click()
                time.sleep(1)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                Chrome_Drive.switch_to_frame("mainFrame")
                time.sleep(1)
                Chrome_Drive.find_element_by_css_selector("[name='keySearch']").clear()
                time.sleep(1)
                Chrome_Drive.find_element_by_class_name("click_input_icon").click()
                time.sleep(1)
                
                #条件测试-申请人
                Chrome_Drive.find_element_by_id("uiid-2459469583305846_open").click()
                Chrome_Drive.implicitly_wait(2) # 因为弹出的窗口是通过js新增的div模块,所以要设置等待后,待页面加载后重新获取Chrome_Drive的页面元素才能定位
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                iframe=Chrome_Drive.find_element_by_xpath("//*[@id='topdialog_uiid-2459469583305846']/div[2]/iframe")
                Chrome_Drive.switch_to_frame(iframe)
                Chrome_Drive.find_element_by_xpath("//*[@id='tree']/ul/li/ul/li[6]/span/a").click()
                Chrome_Drive.find_element_by_xpath("//*[@id='tree']/ul/li/ul/li[6]/ul/li[7]/span/a").click()
                Chrome_Drive.find_element_by_xpath("//*[@id='tree']/ul/li/ul/li[6]/ul/li[7]/ul/li[1]/span/a").click()
                Chrome_Drive.find_element_by_xpath("//*[@id='ok']/a").click()
                
                #清空还原,重新加载框架
                Chrome_Drive.implicitly_wait(2)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                Chrome_Drive.switch_to_frame("mainFrame")
                Chrome_Drive.find_element_by_xpath("//*[@id='btnClearQuery']/a").click()
                Chrome_Drive.implicitly_wait(2)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                Chrome_Drive.switch_to_frame("mainFrame")
                time.sleep(2)

                #流程状态选择测试,清空条件
                Chrome_Drive.find_element_by_xpath("//*[@id='uiid-9333555011841209']/div[1]/a").click()
                time.sleep(2)
                Chrome_Drive.find_element_by_xpath("/html/body/div[3]/div/a[2]").click()
                Chrome_Drive.implicitly_wait(2)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                Chrome_Drive.switch_to_frame("mainFrame")
                Chrome_Drive.find_element_by_xpath("//*[@id='btnClearQuery']/a").click()
                Chrome_Drive.implicitly_wait(2)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                Chrome_Drive.switch_to_frame("mainFrame")
                time.sleep(2)

                #申请部门测试,清空条件
                Chrome_Drive.find_element_by_id("uiid-20383743069464813_open").click()
                Chrome_Drive.implicitly_wait(2)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                iframe=Chrome_Drive.find_element_by_xpath("//*[@id='topdialog_uiid-20383743069464813']/div[2]/iframe")
                Chrome_Drive.switch_to_frame(iframe)
                time.sleep(2)
                Chrome_Drive.find_element_by_xpath("//*[@id='tree']/ul/li/ul/li[6]/span/a").click()
                time.sleep(2)
                Chrome_Drive.find_element_by_xpath("//*[@id='ok']/a").click()
                time.sleep(2)
                Chrome_Drive.implicitly_wait(2)
                Chrome_Drive.switch_to_window(Chrome_Drive.window_handles[1])
                Chrome_Drive.switch_to_frame("mainFrame")
                Chrome_Drive.find_element_by_xpath("//*[@id='btnClearQuery']/a").click()

            elif table.text=="固定资产情况表":
                print("固定资产情况表")
            
            else:
                print("资产卡片查询")

你期待的结果是什么?实际看到的错误信息又是什么?

2019-04-28 提问
0 个回答

撰写答案

推广链接