Chrome webdriver (Selenium) halts execution after fetch for a specific element

114 Views Asked by At

Using chromeDriver (84.0.4147.30) in Selenium (with Python), the programs halts when a specific element is fetched and wait for user action (e.g, pressing ALT key), keep the execution as if no time has passed (the WebDriverWait doesn't triggers a time exception independently of the passed time).

I have already changed the browser capability (['pageLoadStrategy'] = 'eager'), Expected_Conditions ( element_to_be_clickable and presence_of_element_located ) without success. I only need to click on a element. Any fetch for it in this point freezes.

It's hard to give you a minimal working example because all of this occurs in a specific and restrict webpage (login is needed and account creation only by administrators). But the initial configuration and the problematic function of my script is given below.

from selenium.webdriver import Chrome as Driver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
#... more imports*

def strange_correction(): #something useful after login page (without this, the execution freezes) o.O
   browser.refresh()
#... more definitions

pathdriver = "path/to/webdriver"
webmainsource = "https://adress"


TIMEOUT = 20    

nav_options= Options()
capabilities = DesiredCapabilities.CHROME.copy()
capabilities['pageLoadStrategy'] = 'eager'

browser = Driver(options=nav_options, executable_path=pathdriver, desired_capabilities=capabilities)
browser.maximize_window()
browser.get(webmainsource)

###### Problematic Function (maybe) ######
def wait_for_xpelement(xpath): 

   WebDriverWait(browser, TIMEOUT).until( EC.element_to_be_clickable(( BY.XPATH, xpath )) )
   return WebDriverWait(browser, TIMEOUT).until( EC.presence_of_element_located(( BY.XPATH, xpath )) )

Naturally, I have changed wait_for_xpelement(xpath) function, sometimes simpler or others more sophisticated. sleep functions don't work as well. Anyway, how I can handle with this problem?

Additional Information: Debian 9, Python 3.8

0

There are 0 best solutions below