简体   繁体   中英

Selenium python getting stuck post driver.get('URL') for Internet Explorer

My selenium script is stuck post driver.get("url") and is not moving forward, later it error out.i am using below code. post executing this is paused for long, I have tried all options from the advance setting of the IE browser

     from selenium import webdriver
     from bs4 import BeautifulSoup
     import time
     from tqdm import tqdm
     email='XXXXX'
     password='XXXXX'

     options = webdriver.IeOptions()

     options.ignore_protected_mode_settings = True

     driver = webdriver.Ie('C:\Program Files (x86)\selenium- 
     3.141.0\selenium\webdriver\ie\IEdriverServer.exe')

     driver.get('https://s2fs.axisbank.com/EFTClient/Account/Login.htm')
     email_box = driver.find_element_by_name('username')
     email_box.send_keys(email)
     pass_box = driver.find_element_by_name('password')
     pass_box.send_keys(password)
     submit_button = driver.find_element_by_id('loginSubmit')
     submit_button.click()
     time.sleep(3)
     File2393= driver.find_element_by_link_text('Checkbox For Item 919020028802393.csv')
     File2393.click()
     time.sleep(1)
     File3303= driver.find_element_by_link_text('Checkbox For Item 920020034873303.csv')
     File3303.click()
     time.sleep(1)
     download = driver.find_element_by_class('icomoon icon-download2 toolbar-button')
     download.click()
     print("File is been downloaded")

You are missing a wait / delay before accessing the first element on the page.
You can simply add a sleep there, like this:

driver.get('https://s2fs.axisbank.com/EFTClient/Account/Login.htm')
time.sleep(10)
email_box = driver.find_element_by_name('username')
email_box.send_keys(email)

But it is better to use explicit waits

well, this URL :-

https://s2fs.axisbank.com/EFTClient/Account/Login.htm

is not loading at all in my browser, but if it works for you then you can try with Explicit wait as below :

options = webdriver.IeOptions()
options.ignore_protected_mode_settings = True
driver = webdriver.Ie('C:\Program Files (x86)\selenium-3.141.0\selenium\webdriver\ie\IEdriverServer.exe')

driver.maximize_window()
driver.implicitly_wait(30)
driver.get("https://s2fs.axisbank.com/EFTClient/Account/Login.htm")
wait = WebDriverWait(driver, 10)
email_box = wait.until(EC.element_to_be_clickable((By.NAME, "username")))
email_box.send_keys('email')

These would be the imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

I think, the site is not reachable, you can try to use the correct URL to access the page,

Accessing the element, you could use the explicitWait

 email_box = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,"element_XPATH")))
 email_box.send_Keys("UserName")

import

from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM