自己试出来的 frame定位

今天在做自动化的时候一直无法对元素定位,运用frame一直不成功,网上各种找解决方法都不行,最终自己通过方法成功定位到元素,代码如下。

        driver.switch_to_frame("topFrame")
        #driver.find_element_by_id("tb_12").click()
        driver.find_element_by_link_text(u"授信管理").click()
        driver.switch_to_default_content()

        #xf=driver.find_element_by_class_name("left")
        #driver.switch_to_frame("leftFrame")
        driver.switch_to_frame("mainFrame")#先定位到mainFrame
        driver.switch_to_frame("leftFrame")#在定位到mainFrame下的leftFrame
        driver.find_element_by_link_text(u"额度审批").click()
        driver.switch_to_default_content()#返回到上一层表单
        while n<=10:
            driver.switch_to_frame("mainFrame")
            driver.switch_to_frame("rightFrame")
            driver.find_element_by_link_text(u"业务员审核").click()
python
原文地址:https://www.cnblogs.com/mtfan01/p/7121585.html