I am using EdgeDriver with Selenium and Python 3
I have been able to fix it by manually creating the js folder, but the EdgeDriver window does not load the page, it is showing Data;, in the address bar. These may be related on unrelated errors.
But the scoped_dir13788_764300980 changes when restarting the cmd prompt.
The abridged code is below:
# importing required package of webdriver
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from time import sleep
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.opera.options import Options
from selenium.webdriver.support.wait import WebDriverWait
import schedule
import time
from random import randint
def job():
while True:
# Instantiate the webdriver with the executable location of MS Edge
browser = webdriver.Edge(r"C:\Users\*****\Desktop\msedgedriver.exe")
sleep(2)
browser.maximize_window()
sleep(2)
browser.get('https://********/) #masked the name of website on purpose
try:
# Get the text box to insert Email using selector ID
myElem_1 = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'anti-myhub')))
sleep(3)
# Entering the email address
myElem_1.click()
The full error is (ip and user names masked):
[20444:17192:0308/100926.524:ERROR:storage_reserve.cc(164)] Failed to open file to mark as storage reserve: C:\Users\*****\AppData\Local\Temp\scoped_dir13788_764300980\Default\Code Cache\js
DevTools listening on ws://127.0.0.1:59454/devtools/browser/416f15a9-5a69-4025-9322-003aa9672acc
Traceback (most recent call last):
File "check.py", line 79, in <module>
job()
File "check.py", line 21, in job
browser = webdriver.Edge(r"C:\Users\******\Desktop\msedgedriver.exe")
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\edge\webdriver.py", line 66, in __init__
desired_capabilities=capabilities)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from tab crashed
(Session info: MicrosoftEdge=**.**.**.**)
I tried to put in the msedge exe in the rool folder and gave the path as "executable_path = '.\msedgedriver.exe'".
Related
I'm trying to take screenshot from specifics urls
It actually works with some Urls but not all of them.
Here is the error I have with this url
(https://candidat.pole-emploi.fr/offres/recherche/detail/136QBXM) :
Traceback (most recent call last):
2022-07-05T02:07:36.878958+00:00 app[worker.1]:
File "/app/main.py", line 132, in <module>
2022-07-05T02:07:36.879133+00:00 app[worker.1]:
driver.get("https://candidat.pole-emploi.fr/offres/recherche/detail/136QBXM")
2022-07-05T02:07:36.879146+00:00 app[worker.1]:
File"/app/.heroku/python/lib/python3.10/site-
packages/selenium/webdriver/remote/webdriver.py", line 447, in get
2022-07-05T02:07:36.879379+00:00 app[worker.1]:self.execute(Command.GET, {'url': url})
2022-07-05T02:07:36.879389+00:00 app[worker.1]:
File"/app/.heroku/python/lib/python3.10/site-
packages/selenium/webdriver/remote/webdriver.py", line 435, in execute
2022-07-05T02:07:36.879613+00:00
app[worker.1]:self.error_handler.check_response(response)
2022-07-05T02:07:36.879625+00:00 app[worker.1]:
File"/app/.heroku/python/lib/python3.10/
sitepackages/selenium/webdriver/remote/errorhandler.py", line 247, in
check_response
2022-07-05T02:07:36.879775+00:00 app[worker.1]: raise
exception_class(message, screen, stacktrace)
2022-07-05T02:07:36.879808+00:00 app[worker.1]:
selenium.common.exceptions.WebDriverException: Message: unknownerror:net::ERR_CONNECTION_RESET
Here is my code :
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
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from PIL import Image
import io
from PIL import ImageOps
op=webdriver.ChromeOptions()
op.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
op.add_argument("--headless")
op.add_argument("--no-sandbox")
op.add_argument("--disable-dev-sh-usage")
op.add_argument("start-maximized")
driver =webdriver.Chrome(executable_path=os.environ.get("CHROMEDRIVER_PATH"),options=op)
driver.get('https://candidat.pole-emploi.fr/offres/recherche/detail/136QBXM/')
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH,'//*
[#id="footer_tc_privacy_button_2"]'))).click()
ac = driver.get_screenshot_as_png()
file_like_object = io.BytesIO(ac)
im = Image.open(file_like_object)
img_byte_arr = io.BytesIO()
file_like_object.save(img_byte_arr, format='PNG')
What is the problem with my code? Are there any alternatives ?
The reason for this error is that the connection couldn't be established.
I'll suggest to:
validate the page is reachable
validate proxi rules
make sure firewall in not blocking
clear browser cache
probably this may help you to shortcut the issue
I am trying to run a python script. But I am constantly getting this error:
selenium.common.exceptions.WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
This is my code:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
import csv
from datetime import date
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
today = date.today()
date_today = today.strftime("%Y-%b-%d")
file_name = 'marchon-stock-update-'+date_today+'.csv'
my_file = open(file_name, 'w')
browser = webdriver.Firefox(executable_path=r'path of geckodriver.exe')
This is the error:
<selenium.webdriver.firefox.firefox_profile.FirefoxProfile object at
0x7fb982ea25e0>Traceback (most recent call last): File
"/home/........./marchon.py", line 16, in <module> browser =
webdriver.Firefox(executable_path=r'/path of geckodriver.exe') File
"/usr/lib/python3.8/site-
packages/selenium/webdriver/firefox/webdriver.py", line 79, in
__init__ executor = ExtensionConnection("127.0.0.1", self.profile,
File "/usr/lib/python3.8/site-
packages/selenium/webdriver/firefox/extension_connection.py", line
52, in __init__ self.binary.launch_browser(self.profile,
timeout=timeout) File "/usr/lib/python3.8/site-
packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in
launch_browser self._wait_until_connectable(timeout=timeout) File
"/usr/lib/python3.8/site-
packages/selenium/webdriver/firefox/firefox_binary.py", line 98, in
_wait_until_connectable raise
WebDriverException(selenium.common.exceptions.WebDriverException:
Message: The browser appears to have exited before we could connect.
If you specified a log_file in the FirefoxBinary constructor, check
it for details.
This error is does not happen when I am running the script locally. How can I overcome this error?
I'm trying to log in to linked in and access the "My network" element. I've tried using id, class, xpath, and nothing works. I also tried waiting for 10 secs for the page to load so that python can access the site but that gives an error too. Here's my code:
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
import time
PATH = "C:\Program Files (x86)\chromedriver.exe"
username=input("Enter linkedin mail id: ")
password=input("Enter password: ")
driver=webdriver.Chrome(PATH)
driver.get("https://in.linkedin.com/")
search = driver.find_element_by_class_name("nav__button-secondary")
search.click()
# logging in to linkedin
search=driver.find_element_by_id("username")
search.send_keys(username)
search.send_keys(Keys.RETURN)
search=driver.find_element_by_id("password")
search.send_keys(password)
search = driver.find_element_by_class_name("login__form_action_container ")
search.click()
search=driver.find_element_by_xpath("//div[#ID='ember748']") # DOESNT WORK
search.click()
I'm able to log in to LinkedIn using my username and password but after that, trying to access my network throws an error. What mistake am I making here?
This is what pops up in cmd:
DevTools listening on ws://127.0.0.1:61153/devtools/browser/4a54a771-4361-4304-a2df-7a366a4f31cc
[27720:25060:0412/123447.314:ERROR:device_event_log_impl.cc(214)] [12:34:47.315] USB: usb_device_handle_win.cc:1056 Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
This is the error I'm getting:
Traceback (most recent call last):
File "C:\Users\vedha\OneDrive\Documents\GitHub\Internship\linkedinT1.py", line 32, in
search=driver.find_element_by_xpath("//div[#ID='ember748']") # DOESNT WORK
File "C:\Users\vedha\AppData\Local\Programs\Python\Python38-32\lib\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\vedha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\vedha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\vedha\AppData\Local\Programs\Python\Python38-32\lib\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":"//div[#ID='ember748']"}
(Session info: chrome=89.0.4389.114)
I tried to open a site in firefox through selenium python, when i run the code it opens firefox after that nothing happens ,
WATCH THIS --> HOW TO USE FIREFOX IN PYTHON & HOW TO SET VALUES IN DROP-DOWN LISTS?
here is the error
bash-3.1$ C:/Users/user/AppData/Local/Programs/Python/Python35-32/python.exe d:/PYTHONS/EXTRACT-NEWS/FFD
RIVER.py
Traceback (most recent call last):
File "d:/PYTHONS/EXTRACT-NEWS/FFDRIVER.py", line 23, in <module>
executable_path=r"D:\\PYTHONS\\DRIVERS\\geckodriver.exe")
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 174, in __init__
keep_alive=True)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "c:\Users\user\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: newSession
WHEN I RUN THE CODE I GOT THIS ERR
HOW TO USE FF IN PYTHON?
THX IN ADVANCE
# Import Libraries
import os
import sys
import time
from selenium import webdriver
import selenium.webdriver.firefox.options
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
# Configure Firefox Options
profile = webdriver.Firefox(
executable_path=r"D:\\PYTHONS\\DRIVERS\\geckodriver.exe")
# 0 means to download to the desktop, 1 means to download to the default "Downloads" directory, 2 means to use the directory
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", download_path)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference(
"browser.helperApps.neverAsk.saveToDisk", "application/x-gzip/text/csv")
os.system("cls")
# firefox_profile=profile
driver = webdriver.Firefox(firefox_profile=profile)
driver.get('https://www.google.com')
print(driver.title)
# driver.quit()
[1]: https://i.stack.imgur.com/T3Bf8.png
To set preference you have to use FirefoxProfile() instead of Firefox()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", '.')
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip/text/csv")
driver = webdriver.Firefox(firefox_profile=profile, executable_path="D:\\PYTHONS\\DRIVERS\\geckodriver.exe")
driver.get('https://www.google.com')
print(driver.title)
BTW: and don't run webdriver.Firefox() two times beacuse Selenium doesn't know how to run two browsers at the same time - and this gave you error message.
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: