简体   繁体   English

Selenium-Python-相同的代码适用于firefox,但适用于chrome则慢10分钟

[英]Selenium - Python - same code works well with firefox but 10min slower with chrome

I want to click a button after an image is visible/ loaded, the test takes 10 min to run with Chrome Vs 0:00:00.029671 with firefox. 我想在可见/加载图像后单击一个按钮,该测试需要10分钟才能在具有Firefox的Chrome Vs 0:00:00.029671上运行。 It's too slow , i'd rather be running test manually. 它太慢了,我宁愿手动运行测试。 How can i have the same time execution ? 我怎样才能同时执行? i'm desperate , taking me days ...with multiple code solution from internet 我很拼命,花了我几天的时间...来自互联网的多种代码解决方案

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()

Execution: 执行:

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

I was told that the website i'm testing works with Hidden Iframe (Comet Programming with Javascript), A basic technique for dynamic web application is to use a hidden iframe HTML element (an inline frame, which allows a website to embed one HTML document inside another). 有人告诉我我正在测试的网站与Hidden Iframe(使用Javascript进行彗星编程)一起工作,动态Web应用程序的一项基本技术是使用隐藏的iframe HTML元素(内嵌框架,该元素可以使网站嵌入一个HTML文档)里面)。 This invisible iframe is sent as a chunked block, which implicitly declares it as infinitely long (sometimes called "forever frame") 此不可见的iframe以块块的形式发送,该块隐式地将其声明为无限长(有时称为“永远帧”)

I checked "development tool"=> Network : it's like the script never stop F12-Network-Chrome , and i think that Chrome is waiting for it to finish, that's why he is too long (Firefox doesn't) 我检查了“开发工具” => Network:就像脚本永远不会停止F12-Network-Chrome一样 ,我认为Chrome正在等待它完成,这就是为什么他太长的原因(Firefox不会)

As a workaround i added this line to force chrome to not wait page loading too long : 作为一种解决方法,我添加了以下行以强制chrome不要等待页面加载时间太长:

driver.set_page_load_timeout(7) driver.set_page_load_timeout(7)

Execution now takes seconds: 执行现在需要几秒钟:

Start:  2019-06-20 13:23:24.746351  
TIMEOUT - Element not found    
Diff =  0:00:07.004282    
disconnect    
Diff =  0:00:07.036196

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python + Selenium代码在Chrome中工作正常,但在Firefox中工作不正常 - Python+selenium code works fine in Chrome, but not in Firefox Python-从日志文件读取10分钟 - Python - read 10min from log file 双击在Firefox中有效,但在chrome中无效(Python / Selenium) - Double click works in Firefox but not chrome (Python/Selenium) 如何在 google appengine Python 中使用 taskqueue.add() 增加 10 分钟的 http 请求 - how to increase 10min http request using taskqueue.add() in google appengine Python JavaScript 适用于 chrome 控制台,但不适用于 firefox 或 selenium 代码 - JavaScript works on chrome console but doesn't work in firefox or selenium code Python selenium选项卡功能在Firefox中运行良好,但在Chrome中运行不正常 - Python selenium tab feature works fine in Firefox but not in Chrome 时间 Dataframe 结束开始列到 10 分钟范围 Dataframe - Time Dataframe with end start columns to 10min range Dataframe Selenium…Program可以在Firefox上正常运行,但不能在Chrome上运行 - Selenium…Program Works Fine for Firefox, but not Chrome 使用TOR获取代理的Python selenium适用于firefox,但不适用于chrome - Python selenium using TOR to get proxies works for firefox, but doesn't work for chrome Pandas 按时间间隔(5 分钟、10 分钟、1 天、1 年)和条目计数分组 - Pandas group by time interval (5min, 10min, 1day, 1year) and count amount of entries
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM