Python Webdriver Manager: Linux Problem on Webdriver Manager for Python - python

Linux Problem on Webdriver Manager Python
Details:
System - Manjaro Linux
IDE: Visueal Studio Code
Currently, I used the Webdriver Manager tutorial in Python to make my work easier. But IE and Edge are giving me problems.
The Integration:
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
Chromium,Chrome and Firefox to some extent, but there I found a workaround that works thanks to Stackoverflow.
When running Edge on Manjaro Linux I get the following error:
ValueError: There is no such driver by url https://msedgedriver.azureedge.net/91.0.864.70/edgedriver_linux64.zip
[WDM] - ====== WebDriver manager ======
[WDM] - There is no [linux64] edgedriver for browser in cache
[WDM] - Trying to download new driver from https://msedgedriver.azureedge.net/91.0.864.70/edgedriver_linux64.zip
So the question is, is there currently no webdriver for Linux that allows to test IE/Edge on Linux as well?
Is there a workaround?

Version you try to download - missing on the server.
Try change url for download. You can check all verions here.
For example you can install valid driver ( other version ) from this url:
https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/92.0.878.0/edgedriver_linux64.zip
Or change code to (specify neeeded and valid version to installation):
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(EdgeChromiumDriverManager(version="92.0.878.0").install())

Try webdriver-manager>=3.5.1.
Selecting EdgeDriver on Linux and executable permissions were fixed in 3.5.1.
Released to pypi today https://pypi.org/project/webdriver-manager/3.5.1/

Related

Selenium Webdriver Manager Doesn't Write in the Console Like Expected

https://www.youtube.com/watch?v=Z3M2GBu8t_k&list=PLL34mf651faPOf5PE5YjYgTRITzVzzvMz&index=11
I've been following this youtube tutorial as I set up Selenium. Once he downloads the webdriver manager and runs his code, he gets a lot of [WDM}... output, but I don't get that.
DeprecationWarning: executable_path has been deprecated selenium python
This link also shows the output that I'm not getting, so I think I'm doing something wrong.
Here's my code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.rcvacademy.com")
driver.maximize_window()
print(driver.title)
driver.close()
And this is my output:
"C:\Program Files\Python311\python.exe" C:\python-selenium\PythonSeleniumProject1\LearningSelenium\AutomationTestv2.py
Home El - RCV Academy
Process finished with exit code 0
What am I doing wrong?
I'm not exactly sure what to try
Those are the information used to appear in the console if you use the older version of webdriver-manager.
I installed webdriver_manager v3.3.0 as you mentioned in the youtube video, I got the below log in the console:
In the latest versions, you won't get that.
You can check by uninstalling the newer version and installing the older version in Pycharm. Go to Python Packages > search and select webdriver-manager > in the right side pane > select delete package. Then you can install the older version from the dropdown and verify.
You just trying to print the title of the page only then what you more expected from the webdriver.
if you want to look over the whole page content, then you can try
print(driver.page_source)
As per webdriver-manager website - with the latest versions, you need to setup the logging process. You can enable logging by running this script:
Setup Logging
import logging
from webdriver_manager.core.logger import set_logger
logger = logging.getLogger("custom_logger")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
logger.addHandler(logging.FileHandler("custom.log"))
set_logger(logger)
You should then be able to carry on as per normal (provided you are using Chrome, and Selenium v4):
Here is the suggested code (which is slightly different to yours):
Code:
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
driver.get("https://www.rcvacademy.com")
driver.maximize_window()
print(driver.title)
driver.close()
Output:
====== WebDriver manager ======
Get LATEST chromedriver version for google-chrome 109.0.5414
Driver [C:\Users\scottc\.wdm\drivers\chromedriver\win32\109.0.5414\chromedriver.exe] found in cache
Home El - RCV Academy
Note:
The amount of information logged will depend on whether or not you currently have the latest driver installed. If you already have the latest driver installed, then you should expect to see minimal lines (as per the output above). However, if you are missing the current driver on your system, you can expect to see a more verbose output.
Logging is optional, and not necessary for successful website analysis.

How do I determine which MS Edge Driver is compatible with my OS Version to enable web automation with Selenium for Python?

I've been using Selenium with the Edge Driver for some time. I've been instantiating my Edge Driver by specifying the executable_path= parameter with no issues. However, I recently switched my web automation project to use the webdriver_manager, i.e., webdriver_manager.microsoft import EdgeChromiumDriverManager. Now, when I command the driver to navigate to any webpage - it opens for one second, then immediately closes. The current troubleshooting step I'm on is ensuring that the Edge Driver I'm using (the one downloaded by using the webdriver_manager module) is compatible with my current OS Version, but now I'm stumped. I don't know how to find which MS Edge Driver is compatible/correct for my current OS build - I see no patterns when comparing the two, e.g.:
My current OS:
The webdriver downloaded by the webdriver_manager:
And here is a link to all MS Edge Drivers:
https://msedgewebdriverstorage.z22.web.core.windows.net/
So, how do I find the Edge Driver that is "right" for my OS? When I look at these two numbers: OS build - 22000.795 and Edge webdriver version - 103.0.1264.77; I see no pattern or way of determining which driver is compatible. Maybe, I'm using the webdriver_manager module improperly? I know I can use the executable path, but I'm under the impression that using the webriver_manager automates the install of new releases for you so you don't have to update your script to new edge drivers in the future.
For additional context, here is my code (using Facebook's domain just as an example):
from selenium import webdriver
from selenium.webdriver.edge.service import Service as EdgeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(service = EdgeService(EdgeChromiumDriverManager().install()))
driver.get('https://facebook.com')
The SeleniumBase driver manager works well with Edge:
from seleniumbase import get_driver
driver = get_driver("edge", headless=False)
driver.get("https://facebook.com")
import time; time.sleep(1)
driver.quit()
(Here's another example using the raw driver manager: raw_browser_launcher.py)
Alternatively, you can use the more simple format with automatic setUp and tearDown, but then you need to run your test with pytest and add --edge as a command-line option to use Edge:
from seleniumbase import BaseCase
class MyTestClass(BaseCase):
def test_facebook(self):
self.open("https://facebook.com")
self.sleep(1)
pytest test_facebook.py --edge
========================= test session starts ==========================
platform darwin -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/michael/github/SeleniumBase/examples, configfile: pytest.ini
plugins: html-2.0.1, xdist-2.5.0, forked-1.4.0, rerunfailures-10.2, ordering-0.6, cov-3.0.0, metadata-2.0.2, seleniumbase-3.5.11
collected 1 item
test_facebook.py .
========================== 1 passed in 4.40s ===========================
It's working now (i.e., with the same code example in my original question, the MS Edge window now opens as commanded and remains open). I found the MS Docs regarding Edge webdriver installation/configuration
https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/?tabs=c-sharp
and here are the steps I followed:
The first step is to ensure that your Edge webdriver ("msedgedriver.exe") version matches your Edge browser version (I read a tech blog that said my OS build version needed to match my "msedgedriver.exe" version - thinking maybe that's wrong now?)
I navigated to About Microsoft Edge in settings: edge://settings/help
which displays my current MS Edge version - It was covered with a prompt to update Edge - so I did. Checked after update and my version was: 104.0.1293.47
On a whim, suspecting that maybe my Edge browser update was the cause for webdriver_manager downloading the incompatible msedgedriver.exe, I attempted to run my script again (exact same one I posted in original question)
And it worked - I checked the msedgedriver.exe version right after and noticed that webdriver_manager downloaded a new version: 104.0.1293 - which matches my current Edge Browser version.
So, I'm not 100% sure what the cause for the webdriver_manager failing to download the correct version (to match my browser) was - but until I updated my MS Edge Browser, no new drivers were installed. Then after update and running the script, the right driver is installed and it's working fine now.

error while running undetected chrome from aws instance

The code which works fine locally is throwing an error when instance is created at AWS,I am very novice at it ,I have installed chrome driver and chrome in the instance..any help is highly appreciated
below is the code until error
import logging
from kiteconnect import KiteConnect
from datetime import datetime,timedelta
import pandas as pd
from time import sleep
from selenium import webdriver
import undetected_chromedriver as uc
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pyotp
driver=uc.Chrome()
error is
"selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at 127.0.0.1:41187 from chrome not reachable"
I wonder if you can you try updating your Chrome driver again and copy it's direct path into your code. Also, check to see if you typed the path in correctly. Something similar to this happened to me before when I didn't have the updated Chrome driver in my code.
This error message...
selenium.common.exceptions.WebDriverException: Message: unknown error: 'ms' must be a double (Session info: headless chrome=98.0.4758.102) (Driver info: chromedriver=2.37.544315
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chrome=98.0
Release Notes of ChromeDriver v98.0 clearly mentions the following :
Supports Chrome version 98
But you are using chromedriver=2.37 which is old and ancient.
So there is a clear mismatch between chromedriver=91.0 and the chrome=96.0.4664.45
Solution
Ensure that:
ChromeDriver is updated to current ChromeDriver v98.0 level.
Chrome Browser is updated to current chrome=98 (as per chromedriver=98.0.4758.48 release notes).

Chromium Edge 91 on a Windows 10 crashes

I am trying to run a simple script to open up a google page on Chromium Edge using Python.
What I have so far is
Import selenium
From selenium import webdriver
Path= “..../msedgedriver.exe”
Driver= webdriver.Edge(executable_path=path)
Driver.get(https://google.com)
Got below error:SessionNotCreatedEcception:session not created from tab crashed(Session info:MicrosoftEdge=91.0.864.41)
Tried several things and searched online but no luck yet.Any help will be much appreciated!
There are some problems in the code you provide, I fixed them and tested it, and it works well. My Edge Version is 91.0.864.41 (Official build) (64-bit).
Below is my sample code and you can also try:
import selenium
from selenium import webdriver
path= "D:\\webdriver\\msedgedriver.exe"
driver= webdriver.Edge(executable_path=path)
driver.get("https://www.google.com/")
Please note to modify the path to you owns and use the absolute path of the WebDriver.
I think it may just be a code problem that causes the error.
If the problem persists, can you please provide more information? Such as what version of selenium are you using and what operating system are you using?

python selenium chrome webdriver giving me data; page

I've been working with the following code, trying to introduce myself to selenium. When it runs, the chrome browser opens, but the page is blank, with no source code a far as I can tell, and 'data;' in the address bar. Any information on why this is happening would be greatly appreciated.
from selenium import webdriver
browser = webdriver.Chrome(service_args = ['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])
url = 'https://www.google.com/'
browser.get(url)
I have also tried it without the service_args and tried it specifying the driver path and both, but get the same result each time
The most possibility is your browser not compatible with the webdriver. Please confirm your browser version and webdriver version.
My chrome version is 60 and chromerdriver is chromedriver_2.30.exe
You can find compatible version from here
Update the chromedriver and Chrome Browser, sometime I also faced this issue.
I don't see any error as such in your code. Though the documentation for service_args is missing in the Selenium-Python API Docs as well as in the ChromeDriver Getting started Doc. But 0096850 clearly suggests service_args is implemented.
The service_args works well at my end. Hence I suspect there is a mismatch between Selenium version, chromedriver version and Chrome version we are using. First and foremost, we have to ensure that our Selenium version, chromedriver version and Chrome version are compatible. You can find the compatibility information on the Downloads page of ChromeDriver individually for each releases.
The Downloads page clearly mentions:
Latest Release: ChromeDriver 2.32 Supports Chrome v59-61
Additionally, you may be required to pass the argument executable_path to mention the absolute path of the chromedriver binary as follows:
Windows 8 based code:
from selenium import webdriver
browser = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe', service_args = ['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])
url = 'https://www.google.com/'
browser.get(url)
I've met the same problem,but I solved it by updating my webdriver
Update your webdriver of chrome ,here is the link https://sites.google.com/a/chromium.org/chromedriver/downloads
If you're using Codeception, start the test with :
$I->amOnPage('/');
simply add this argument to selenium options (google how add options on solenium python to how to add options argument)
options.add_argument("--remote-debugging-port=9225")

Categories