Reputation: 310
I am trying to click and selecting values on username and password field, but its 'modal-dialog', which is making things impossible for me. Modal appears right after this URL is opened and ran successfully.
I am using following code:
import time
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get('https://app.staging.showcare.io/product-showcase')
wait = WebDriverWait(driver, 20)
wait.until(EC.title_contains("Signin"))
print('sign in')
print('wait')
userName_field = driver.find_element_by_name('username')
time.sleep(6)
userName_field.click()
userName_field.send_keys('')
driver.quit()
I know I am using time.sleep, which is not considered best practice, but I am trying to take time of it. I have used wait till click as well, its not working. Right now, exception it is throwing is this:
Traceback (most recent call last):
File "/Users/tp/Documents/Pract/ShowCase_Automation/exhibitorAccess.py", line 19, in <module>
userName_field.click()
File "/Users/tp/Documents/Pract/ShowCase_Automation/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "/Users/tp/Documents/Pract/ShowCase_Automation/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "/Users/tp/Documents/Pract/ShowCase_Automation/venv/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Users/tp/Documents/Pract/ShowCase_Automation/venv/lib/python3.8/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=93.0.4577.82)
Can someone help me on this?
Upvotes: 1
Views: 1161
Reputation: 33361
There are 2 elements matching find_element_by_name('username')
on that page.
To access the correct element you should change your locator.
use this instead:
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get('https://app.staging.showcare.io/product-showcase')
wait = WebDriverWait(driver, 20)
wait.until(EC.title_contains("Signin"))
print('sign in')
print('wait')
userName_field = wait.until(EC.visibility_of_element_located((By.XPATH, "//div[contains(@class,'modal-content') and(contains(@class,'visible-lg'))]//input[@name='username']")))
userName_field.click()
userName_field.send_keys('')
time.sleep(6)
Upvotes: 1