-1

我想在图像可见/加载后单击一个按钮,使用 Chrome Vs 0:00:00.029671 和 firefox 运行测试需要 10 分钟。太慢了,我宁愿手动运行测试。我怎样才能同时执行?我很绝望,花了我几天的时间......来自互联网的多个代码解决方案

I upgrade google Chrome 75.0.3770.90 and ChromeDriver
I added some options to run chrome :(not very helpful in this case)
      options.add_argument('--no-sandbox')  
      options.add_argument('--disable-gpu')  
      options.add_argument('start-maximized') 
      options.add_argument('disable-infobars')
      options.add_argument("--disable-extensions")

connectionStatus = True

while connectionStatus == True:
    try:
        WebDriverWait(conn.driver, 10).until(ec.visibility_of_element_located(
            (By.CSS_SELECTOR, "img[src='../public/images//disconnect.png']")))
        element = conn.driver.find_element(By.CSS_SELECTOR, 'img[src="../public/images//disconnect.png"]')
        element.is_displayed

        print("disconnect")
        connectionStatus = False
    except NoSuchElementException as e:
        print("Waiting for M to disconnect from VW")
        time.sleep(10)
    except TimeoutException:
        print("TIMEOUT - Element not found: ")

    conn.driver.find_element(By.CSS_SELECTOR, "#btnSendUpd").click()

执行:

Start:  2019-06-18 16:13:06.710734
TIMEOUT - Element not found: 
Diff =  0:05:00.004450
disconnect
Diff =  0:05:00.046355


NB: the code html contains only css , not ID to use findElementById

Windows 10 - 64bits(I use chromedriver 32bits-they say that is working on 64bits)
Selenium 3.141.0
4

1 回答 1

1

有人告诉我,我正在测试的网站使用隐藏 iframe(使用 Javascript 进行彗星编程),动态 Web 应用程序的基本技术是使用隐藏 iframe HTML 元素(内联框架,它允许网站嵌入一个 HTML 文档在另一个里面)。这个不可见的 iframe 作为一个分块发送,隐含地声明它为无限长(有时称为“永久帧”)

我检查了“开发工具”=> 网络:就像脚本永远不会停止F12-Network-Chrome,我认为 Chrome 正在等待它完成,这就是他太长的原因(Firefox 没有)

作为一种解决方法,我添加了这一行来强制 chrome 不要等待页面加载太久:

driver.set_page_load_timeout(7)

执行现在需要几秒钟:

Start:  2019-06-20 13:23:24.746351  
TIMEOUT - Element not found    
Diff =  0:00:07.004282    
disconnect    
Diff =  0:00:07.036196
于 2019-06-20T11:30:53.963 回答