Reputation: 1
I am trying to use webdriver to click the login button and the page has transformed correctly.but the program stop and occured the proplem "selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable" and this is the code where occured problems
browser.find_element_by_xpath(
'//*[@id="emap-rsids-content"]/div/div[3]/div/div[1]/div/div/div/input').send_keys(uid)
browser.find_element_by_xpath(
'//*[@id="emap-rsids-content"]/div/div[3]/div/div[2]/div/div/div/input').send_keys(pwd)
# click to sign in
browser.find_element_by_xpath('//*[@id="emap-rsids-content"]/div/div[3]/div/div[3]/div/button').send_keys(Keys.ENTER)
time.sleep(3)
browser.find_element_by_xpath('/html/body/main/article/section[1]/div/div/div/div[2]/div/div/div[2]/div[2]').click()
Traceback (most recent call last):
File "C:/Users/14638/Desktop/auto_sign_zzu_jksb-master/auto_sign.py", line 68, in sign_in
time.sleep(3)
File "C:\Users\14638\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\14638\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\14638\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\14638\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
(Session info: chrome=83.0.4103.116)
''' browser.find_element_by_xpath('//*[@id="emap-rsids-content"]/div/div[3]/div/div[3]/div/button').click() '''
and another is
''' pages=browser.find_element_by_xpath('//*[@id="emap-rsids-content"]/div/div[3]/div/div[3]/div/button') browser.execute_script("arguments[0].click();", pages) '''
but still not work
Upvotes: 0
Views: 69
Reputation: 1769
You need to update the page_source:
browser.find_element_by_xpath(
'//*[@id="emap-rsids-content"]/div/div[3]/div/div[1]/div/div/div/input').send_keys(uid)
browser.find_element_by_xpath(
'//*[@id="emap-rsids-content"]/div/div[3]/div/div[2]/div/div/div/input').send_keys(pwd)
# click to sign in
time.sleep(5) # add some time to load the page
browser.get(browser.current_url)
time.sleep(1)
browser.find_element_by_xpath('//*[@id="emap-rsids-content"]/div/div[3]/div/div[3]/div/button').send_keys(Keys.ENTER)
time.sleep(3)
browser.find_element_by_xpath('/html/body/main/article/section[1]/div/div/div/div[2]/div/div/div[2]/div[2]').click()
Upvotes: 0
Reputation: 183
I think you are trying to click the element which is not completely loaded.What you have to do is wait till that happens.
First import these files
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
Then add this after logging in.
WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, '/html/body/main/article/section[1]/div/div/div/div[2]/div/div/div[2]/div[2]')))
Then do
browser.find_element_by_xpath('/html/body/main/article/section[1]/div/div/div/div[2]/div/div/div[2]/div[2]').click()
Upvotes: 1