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

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.

Related

Problems with Chrome webdriver

Getting started with using Chrome webdrivers and selenium. When I execute the code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Chrome(executable_path = \
r"C:\Users\payto\Downloads\chromedriver_win32.zip\chromedriver.exe")
I keep getting this error:
WebDriverException: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
I've looked up how to solve it, but anything I see says to install a webdriver...which I've already done. My Chrome version is 107 and that's the one I downloaded, so it should be working but it's not. Any tips?
You can use webdriver_manager instead of constantly setting executable_path and chromedriver yourself.
For chrome driver:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
it will automatically download the appropriate chromedriver. if it's already loaded, it finds it in the cache and uses it directly.
Solution
You can get rid of all driver versions issues by using ChromeDriverManager
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.maximize_window()
driver.get("https://www.google.com")
OR Fixing the issue in your existing code like ..
Downloading a specific version of ChromeDriver you can use the following code block:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service('C:/Users/hp/Downloads/chromedriver/chromedriver.exe')
driver = webdriver.Chrome(service=s)
You can find more discussion here, hope this will help you.
You actually have to install the Chrome Browser on you machine.
Go to https://www.google.com/intl/en_en/chrome/, download and install it.
It is needed to run Selenium/ Chrome.

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).

Python Webdriver Manager: Linux Problem on Webdriver Manager for 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/

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