This question already has answers here:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable when clicking on an element using Selenium Python
(6 answers)
Closed 2 years ago.
I am trying to click on button that will allow to me download a cdv in order to run daily checks, but the moment I tried to do it it thrown me an error like this
ElementNotInteractableException: Message:
this is my code:
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Safari()
driver.get('https://xxxxxxxxxx')
id_box = driver.find_element_by_xpath("//input[#id='ap_email']")
Send id information
id_box.send_keys('xxxxxx')
pass_box = driver.find_element_by_xpath("//input[#id='ap_password']")
pass_box.send_keys('xxxxxxx')
Find login button
login_button = driver.find_element_by_xpath("//input[#id='signInSubmit']")
Click login
login_button.click()
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.CLASS_NAME,"tours-controls__export")))
element.click()
I TRIED ALSO:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(text(),'Export')]"))).click()
AND :
ele = driver.find_element_by_xpath("//body/div[#id='body-wrapper']/main[#id='main-wrapper']/div[#id='application']/div1/div[2]/div1/div1/div[2]/div[4]/span1/span1")
but still the same error.
Below the html:
enter image description here
Export
when I click manually it change adding "disabled"
Export
ElementNotInteractableException occurs when an element is found, but
you can't be interacted with. For instance, you may not be able to
click or send keys. This could happen due to various reasons like
element being not visible or displayed, element is off screen or
element is behind another element or hidden. So, you can perform some
of the actions to make element interactable:
Check for overlays, check that element is displayed, (not in a "collapsed" or hidden state).
element_to_be_clickable doesn't mean it is actually "clickable" if you will. It checks some factors (non-zero size, not disabled, etc) but isn't a guarantee that the element will succeed a click.
Check to make sure the element is actually present on the rendered page.
Related
I am trying to navigate a scheduling website to eventually auto populate a schedule using the following script:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
# Create a Chrome webdriver
driver = webdriver.Chrome(r'C:\Users\chromedriver_win32\chromedriver.exe')
# Navigate to https://www.qgenda.com/
driver.get('https://www.qgenda.com/')
# Wait for the page to load
driver.implicitly_wait(5) # 5 seconds
# You can now interact with the page using the webdriver
# Locate the sign in button
sign_in_button = driver.find_element(By.XPATH,'/html/body/div[1]/div/header[3]/div/div[3]/div/div/div/div/a')
# Click the sign in button
sign_in_button.click()
# Find the input element
input_email = driver.find_element(By.XPATH,'//*[#id="Input_Email"]')
# Send text
input_email.send_keys('Josh')
However, I cannot seem to find the Input_Email object. I've tried all the Xpaths and Id's that make sense and also tried waiting until the object is clickable with no luck. Would really appreciate some guidance on this.
I was expecting Selenium to find the html object form box and pass in text but instead I get an error:
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[#id="Input_Email"]"}
even though the Xpath definitely exists.
The XPath seems fine. I am guessing you need to do some explicit wait or implicit wait to ensure the page is fully loaded before allocating the element.
Another thing I would like to point out is that given the login URL is available. Locating the sign in button seems to be redundant. You can access it directly via driver.get('https://login.qgenda.com/')
For instance,
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver.get('https://login.qgenda.com/')
input_email = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, '//*[#id="Input_Email"]'))
)
input_email.send_keys('Josh')
You can read more about it here.
I have a script that uses Selenium (Python).
I tried to make the code click a button that it acknowledges is clickable, but throws an error stating it;s not clickable.
Same thing happens again in a dropdown menu, but this time I'm not clicking, but selecting an option by value.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import *
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Getting to Chrome and website
website = 'https://www.padron.gob.ar/publica/'
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get(website)
driver.maximize_window()
#"BUENOS AIRES" in "Distrito Electoral"
distritoElectoralOptions = driver.find_element(By.NAME, 'site')
Select(distritoElectoralOptions).select_by_value('02 ')
#Clicking "Consulta por Zona
WebDriverWait(driver, 35).until(EC.element_to_be_clickable((By.ID, 'lired')))
consultaPorZona = driver.find_element(By.ID, 'lired')
consultaPorZona.click()
#"SEC_8" in "Sección General Electoral"
WebDriverWait(driver, 35).until(EC.visibility_of((By.NAME, 'secg')))
seccionGeneralElectoral = driver.find_element(By.NAME, 'secg')
Select(seccionGeneralElectoral).select_by_value('00008')
I'm getting this error on line 21:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: element has zero size
It works in a ipython notebook if each section is separated, but only if the option "Run all" is not used. Instead, the kernel has to be run on it's own.
I'm using VS Code.
Also, when it reaches the last line, when run in ipynb format, it throws this error:
Message: Cannot locate option with value: 00008
Thank you in advance.
When a web element is present in the HTML-DOM but it is not in the state that can be interacted. Other words, when the element is found but we can’t interact with it, it throws ElementNotInteractableException.
The element not interactable exception may occur due to various reasons.
Element is not visible
Element is present off-screen (After scrolling down it will display)
Element is present behind any other element
Element is disabled
If the element is not visible then wait until element is visible. For this we will use wait command in selenium
wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))
element.click()
If the element is off-screen then we need to scroll down the browser and interact with the element.
Use the execute_script() interface that helps to execute JavaScript methods through Selenium Webdriver.
browser = webdriver.Firefox()
browser.get("https://en.wikipedia.org")
browser.execute_script("window.scrollTo(0,1000)") //scroll 1000 pixel vertical
Reference this solution in to the regarding problem.
I am trying to send keys to username and password so I can log in in the following website (yes, mobile version):
https://m.bancosecurity.cl/
I always get the same error:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: [object HTMLInputElement] has no size and location
(Session info: chrome=91.0.4472.164)
My code is:
Username = driver.find_element_by_xpath('//*[#id="UserName"]')
driver.execute_script("arguments[0].click();", Username)
Username.send_keys("xx.xxx.xxx-x")
The code that produces the error is:
Username.send_keys("xx.xxx.xxx-x")
Thanks!
I can see there are multiple input on the page So tried to access it with the help element indexes
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
username= WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "((//input[#id='UserName'])[2])")))
username.send_keys("Username")
password= WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "((//input[#id='Password'])[2])")))
password.send_keys("passowrd")
So above I have just checked the presence of the element with excplicitWait and send_keys to the input
There are 2 elements matching //*[#id="UserName"] XPath selector on that page. The first is not the filed receiving user input with send_keys.
So clicking on it, especially clicking with JavaScript on it just does nothing while sending a string input to it with Selenium send_keys is not allowed.
You should do 2 things to make your code working here:
Set explicit wait to make the page loaded before accessing the element.
To use correct locator.
Try this:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 20)
username = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[#class='panel' and contains(#style,'block')]//*[#id='UserName']")))
username.click()
username.send_keys("xx.xxx.xxx-x")
This question already has answers here:
Select iframe using Python + Selenium
(7 answers)
Closed 1 year ago.
I want to capture the web element highlighted in the below screenshot:
I have already tried following options (using absolute as well as relative path):
submit = driver.find_element_by_xpath("html/body/vra-root/vra-shell/clr-main-container/vra-tabs/nav/ul/li[2]/a").click()
submit = driver.find_element_by_xpath("//ul[#class='nav']//li[#class='nav-item ng-star-inserted']//a[#id='csp.cs.ui.deployment'] and contains [text()='Deployments']").click()
submit = driver.find_element_by_xpath("//a[text()='Deployments']").click()
content = driver.find_element_by_css_selector('a.nav-link').click()
But, everytime I am getting the follwing error message`NoSuchElementException: Message: no such element: Unable to locate element:
I am new to this, any help is appreciated!`
This looks like in an iframe, if yes then you can switch it to iframe first like this :
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"iframe xpath")))
and then click :
driver.find_element_by_xpath("//a[text()='Deployments']").click()
If it's not an iframe issue as #cruisepandy described then try adding a wait around it to see if that helps
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 10)
submit = wait.until(EC.element_to_be_clickable((By.XPATH, "//a[text()='Deployments']")))
submit.click()
This question already has answers here:
Ways to deal with #document under iframe
(2 answers)
Closed 2 years ago.
Actually my code is simple and the task too, but somehow i get this Error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"TLoginBox"}
I tried any of the find element and find element by options but none did work.
All i found out is that on the website where the login button is, that the button itself somehow is a whole HTML with head, body,...
T-online Email Link
That's my code:
from selenium.webdriver.common.by import By
from time import sleep
from selenium import webdriver
browser = webdriver.Chrome('F:/trzttrtz/chromedriver_win32/chromedriver')
browser.get('https://www.t-online.de/themen/e-mail')
sleep(5)
login = browser.find_element(By.ID, value="TLoginBox")
login.click()
I am new to programming, so any help means a lot.
Thanks in advance.
The element cannot be found because it is inside another frame, try the following:
from selenium.webdriver.common.by import By
from time import sleep
from selenium import webdriver
browser = webdriver.Chrome('F:/trzttrtz/chromedriver_win32/chromedriver')
browser.get('https://www.t-online.de/themen/e-mail')
frame = browser.find_element(By.CLASS_NAME, 'TlgnBoxIfr')
browser.switch_to_frame(frame)
login = browser.find_element(By.CLASS_NAME, value='TlogBtn')
login.click()
If you want to go back to the main frame use:
browser.switch_to().default_content()
The element with the text as E-Mail Login is within an <iframe> so you have to:
Induce WebDriverWait for the desired frame to be available and switch to it.
Induce WebDriverWait for the desired element to be clickable.
You can use either of the following Locator Strategies:
Using CSS_SELECTOR:
driver.get('https://www.t-online.de/themen/e-mail')
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe.TlgnBoxIfr")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.TlogBtn>span.mailicn>img"))).click()
Using XPATH:
driver.get('https://www.t-online.de/themen/e-mail')
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[#class='TlgnBoxIfr']")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[#class='TlogBtn']/span[#class='mailicn']/img"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Browser Snapshot:
Reference
You can find a couple of relevant discussions in:
Ways to deal with #document under iframe
Switch to an iframe through Selenium and python