I am searching to do a program for fun but i have some problems with selenium and i
need some help...
This is the programm (i deleted the directory of webdriver because the folder's name contain the name of an other person)
from selenium import webdriver
import webbrowser
import time
def Pass_send_():
driver=webdriver.Chrome()
driver.get('chrome://flags/#password_export-enable')
ricerca=driver.find_element_by_id("search")
ricerca.send_keys('password export')
scorritore=driver.find_element_by_class_name('experiment-select')
scorritore.click()
Pass_send_()
And so the purpose it's easy, it should open a windows, type a text and click a button. everything works but the click doesn't and this is the error:
Traceback (most recent call last):
File "C:\Python34\internet22.py", line 18, in <module>
Pass_send_()
File "C:\Python34\internet22.py", line 14, in Pass_send_
scorritore.click()
File "C:\Python34\lib\site-
packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python34\lib\site-
packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Python34\lib\site-
packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-
packages\selenium\webdriver\remote\errorhandler.py", line 242, in
check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable
So i am not an expert but it says: element not intercatable? what does it mean and how can i fix it? i would really appreciate a reply...
To send a character sequence to the search box within the webpage chrome://flags/#password_export-enable you need to induce WebDriverWait and you can use the following solution:
Code Block:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
options = Options()
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument('--disable-extensions')
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get('chrome://flags/#password_export-enable')
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#search"))).send_keys("password export")
Browser Snapshot:
Related
I tried to automate the login to the site using Selenium, everything worked well on other sites.
When I tried to enter my username in the field I encountered an error :
File "C:\Users\BOY4ik\PycharmProjects\pythonProject\main.py", line 17, in <module>
input_login.send_keys('u.t.x.c.x.z.2.9.0#gmail.com')
File "C:\Users\BOY4ik\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 477, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT,
File "C:\Users\BOY4ik\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "C:\Users\BOY4ik\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\BOY4ik\AppData\Local\Programs\Python\Python39\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=91.0.4472.101)
Link: https://all-access.wax.io/
MY CODE
browser = webdriver.Chrome()
browser.get('https://all-access.wax.io/')
time.sleep(2)
input_login = browser.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div[5]/div/div/div/div[1]/div[1]/input')
browser.execute_script("arguments[0].click();", input_login)
input_login.send_keys('LOGIN')
input_pass = browser.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div[5]/div/div/div/div[1]/div[2]/input')
input_pass.send_keys('PASS')
time.sleep(30)
sign_up=browser.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/div[5]/div/div/div/div[5]/button[2]')
sign_up.click()
time.sleep(1)
browser.switch_to.window(browser.window_handles[0])
Okay The below solution assumes that OP can handle captcha using AntiCaptcha.
wait = WebDriverWait(driver, 10)
driver.get("https://all-access.wax.io")
wait.until(EC.element_to_be_clickable((By.NAME, "userName"))).send_keys("Login user name here")
wait.until(EC.element_to_be_clickable((By.NAME, "password"))).send_keys("Login password here")
and OP will handle captcha here :
then click on Login button like this :
ActionChains(driver).move_to_element(wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Login']")))).click().perform()
Imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
im stuck trying to input email and pass on a web page. I toke xpath from email input but when I execute the code I get a error in the consol.
import time
from datetime import date
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
options = Options()
browser = webdriver.Chrome('C:/chromedriver.exe',chrome_options=options)
browser.get('https://app.buenbit.com/dashboard')
usuario = browser.find_element_by_xpath('//*[#id="root"]/div/div[3]/div[1]/form/div[1]/input')
browser.quit()
this is the error
Traceback (most recent call last):
File "c:/proyectos/SCRAPY/MercadoLibre HIDE.py", line 12, in
usuario = browser.find_element_by_xpath('//[#id="root"]/div/div[3]/div[1]/form/div[1]/input')
File "C:\Users\vrodrig5\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\vrodrig5\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\vrodrig5\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\vrodrig5\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//[#id="root"]/div/div[3]/div[1]/form/div[1]/input"}
(Session info: chrome=81.0.4044.138)
To login within the website https://app.buenbit.com/ using a valid set of credentials you need to induce WebDriverWait for the desired element_to_be_clickable() and you can use either of the following Locator Strategies:
Using CSS_SELECTOR:
driver.get("https://app.buenbit.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='email']"))).send_keys("Victor_Rodriguez")
Using XPATH:
driver.get("https://app.buenbit.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[#name='email']"))).send_keys("Victor_Rodriguez")
Browser Snapshot:
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
I'm trying to click the "Login" button on this website, with Selenium : https://results.decisiondeskhq.com/2020/primary/colorado/president. I right clicked the element in inspect element, copied the xpath, and put it into the find_element_by_xpath function.
Here's my code:
from selenium import webdriver
driver = webdriver.Chrome(executable_path="/users/aliallam/Desktop/scraper test/chromedriver")
url = 'https://results.decisiondeskhq.com/2020/primary/colorado/president'
driver.get(url)
driver.find_element_by_xpath('//*[#id="content"]/div/div/div/div/button').click()
This is the error message I get:
Traceback (most recent call last):
File "/Users/aliallam/Desktop/scraper test/sandbox2.py", line 7, in <module>
driver.find_element_by_xpath('//*[#id="content"]/div/div/div/div/button').click()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[#id="content"]/div/div/div/div/button"}
(Session info: chrome=80.0.3987.149)
Thank you in advance!
You need to wait until the webpage load to select the button. You need to import
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
adding the delay and wait before select the element like this:
delay = 10 # seconds
WebDriverWait(driver, delay).until(
EC.presence_of_element_located((By.CLASS_NAME, 'signup-boxes')))
# you can select element that you want ini here
for more resource visit here
The element has an unique id, so instead of using xpath, you should use the id and you should apply explicit wait on the element so that the script waits until the element is present and as there is a div of element present above the element that you are trying to click, you need to use java script click in this case.
Your code should be like:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(executable_path="/users/aliallam/Desktop/scraper test/chromedriver")
url = 'https://results.decisiondeskhq.com/2020/primary/colorado/president'
driver.get(url)
element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "login-text-btn")))
driver.execute_script("arguments[0].click();", element)
I am trying to scrape the following website: https://www.nemlig.com/ but it is not as easy as I was used to, as the page I am trying to scrape things off is not static. What I am trying to do using Selenium is click this:
So that the zipcode pop-up is visible. Then, insert a number and hit enter.
This is my take on it:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome(executable_path=r"C:\Users\user\lib\chromedriver_77.0.3865.40.exe")
browser.get('https://www.nemlig.com/')
elem = browser.find_element_by_xpath("//div[#class='timeslot-statusbutton']")
elem.clear()
elem = browser.find_element_by_xpath("//input[#class='prompt__input ng-pristine ng-valid ng-empty ng-touched']")
elem.send_keys("2300")
elem.send_keys(Keys.RETURN)
But everything after browser.get returns me this error:
Traceback (most recent call last):
File "", line 8, in
elem = browser.find_element_by_xpath("//div[#class='timeslot-statusbutton']").click()
File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
ElementNotInteractableException: element not interactable
(Session info: chrome=77.0.3865.90)
How can I do this properly?
You can try this code :
driver = webdriver.Chrome(executable_path = r'C:/Users/***/Downloads/BrowserDriver/chromedriver_win32/chromedriver.exe')
wait = WebDriverWait(driver,10)
driver.maximize_window()
driver.get("https://www.nemlig.com/")
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".timeslot-prompt.initial-animation-done")))
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[type='tel'][class^='pro']"))).send_keys('ABC')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".btn.prompt__button"))).click()
imports will be :
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
I am using the following script to find elements called 'service_notes' and click the first of them:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import os
driver = webdriver.Firefox(executable_path=r'geckodriver.exe')
driver.get("https://.../sites/frontiersupport/servicenotes/Pages/default.aspx")
os.system("java -jar sikulix.jar -r login.sikuli")
driver.implicitly_wait(5) #
service_notes = driver.find_elements(By.XPATH, '//*/a[starts-with(#href, "/sites/frontiersupport/servicenotes/Lists/SNotes/DispForm.aspx")]')
print(str(service_notes[0]) + ' is the first service note')
print(len(service_notes))
service_notes[0].click()
According to the log, the element is found, but for some reason I can't click it:
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="7505cfd0-5f41-4a8c-af28-bca639e13332", element="c81518a8-5f6c-42fa-8089-5f9469423d7c")> is the first service note
10
Traceback (most recent call last):
File "scraper.py", line 19, in <module>
service_notes[0].click()
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Users\Joseph\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoAlertPresentException: Message: No modal dialog is currently open
The browser is defniitely open, and I'm not sure why the driver is looking for an open 'modal dialog'. This should simply be clicking a link. Any ideas?
Here's the HTML of the link I want to click:
<a onfocus="OnLink(this)" href="/sites/frontiersupport/servicenotes/Lists/SNotes/DispForm.aspx?ID=14686" onclick="GoToLink(this);return false;" target="_self">Firmware 3.04 released for the 850-DS <img src="/_layouts/images/blank.gif" class="ms-hidden" alt="Use SHIFT+ENTER to open the menu (new window)." width="1" height="1" border="0"></a>
I've encountered this problem of not being able to click on elements too. One way I found to go around it was to use execute_script method. In your case -
driver.execute_script("arguments[0].click();", service_notes[0])