I wonder if there is a way to combine execute_script()
and WebdriverWait
. Currently I have the following code:
network_list = driver.find_element_by_xpath('//*[@id="folder_box"]/div[1]/div/div[2]/div[1]')
wait = WebDriverWait(driver, 4)
try:
wait_network_list = wait.until(EC.element_to_be_clickable((By.XPATH, 'network_list')))
except:
driver.execute_script("arguments[0].click();", network_list)
The code does what it's supposed to do, but I guess this is a ugly way. Is there a way to combine my try and except statement to one line of code?