Open asifhg opened 1 year ago
Your tutorial documentation uses: selenium-server-standalone-2.38.0.jar I want to try using WebDriver with selenium-server-standalone-2.38.0.jar. But I'm unable to find this version of the jar file: https://github.com/SeleniumHQ/selenium/tags?after=selenium-2.40.0 I will have to download the src tarball and build it, which I do not want to do.
I tried each of the Selenium-Server versions backwards and found that version 4.8.3 works. The tcl instruction: set session [WebDriver::Session #auto $seleniumServer/wd/hub $caps] ; starts an instance of the Firefox browser.
I wonder if this is simply an incompatibility between the browser and the latest selenium server. Are you using a recent version of Firefox or some LTS version maybe?
Hm, no, it also doesn't work with chromedriver.
Then probably some backwards-compatibility was removed. This Tcl module was written years ago, even before WebDriver became a W3C standard, so there may be things in there that simply aren't compliant with the standard.
It's probably about how the session is being requested. I see things have changed. There are no desiredCapabilites and requiredCapabilities anymore. Instead there is alwaysMatch and firstMatch.
Firefox Version Whatever the latest for Ubuntu 22.04 is: 113.0.2 (64-bit)
Would be useful to get the minimal tcl code to make Selenium-Webdriver start chrome instead of firefox. I tried the following to no avail:
java -jar selenium-server/selenium-server-4.8.3.jar standalone --host 127.0.0.1 --port 4445 --http-logs true --log-level INFO --service-configuration stereotype='{"browserName": "chrome"}' ;
But then the same cmd in the following for firefox fails:
java -jar selenium-server/selenium-server-4.8.3.jar standalone --host 127.0.0.1 --port 4445 --http-logs true --log-level INFO --service-configuration stereotype='{"browserName": "firefox"}' ;
I am able to do the following successfully.
Server
java -jar selenium-server/selenium-server-4.8.3.jar standalone --host 127.0.0.1 --port 4445 --http-logs true --log-level INFO ;
Client
/usr/bin/tclsh ;
package require WebDriver ;
set caps [ namespace which [ WebDriver::Capabilities #auto -browser_name firefox ]] ;
set session [ WebDriver::Session #auto http://127.0.0.1:4445/wd/hub $caps ] ;
# Now we have a running instance of the firefox browser.
set window [$session active_window] ;
set url "https://duckduckgo.com" ;
$window set_url $url ;
# Now the browser has opened the website.
set elements_name [ $window elements by_xpath {//*[@name]} ] ;
set e_search_field [ lindex $elements_name end-1 ] ;
set e_search_button [ lindex $elements_name end ] ;
$e_search_field click ;
$e_search_field clear ;
$e_search_field send_keys "google" ;
$e_search_button submit ;
I'm no Itcl expert, so debugging this is a challenge. But then again, there's nothing to debug for the above simple experiment. I'm going to keep going further with my experimentations such as loging into a legit a/c and report back and take it further.
I want to use Caius to be able to launch the Firefox browser with a specific user profile. I tried to look through the source code, but I'm not sure whether passing cmdline args to Firefox is supported. Any help would be much appreciated. To illustrate, here is a simple example in Python3 Selenium. 1) Init user profile in cmdline options passed to Firefox. 2) Launch Firefox. 3) Load URL: about:profiles 4) Exit
OS Platform
lsb_release -a ;
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
Installation
sudo apt-get install python3 python3-pip ;
pip3 install selenium webdriver-manager ;
pip3 install -U selenium ;
pip3 install -U webdriver-manager ;
Prequisites
# Create Firefox user profile and note the location of the user profile directory.
firefox -ProfileManager ;
web_user_profile.py
import sys
import time
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
options = Options()
options.page_load_strategy = 'normal'
profile_arg_param = '-profile'
# This is usually where the Firefox user profile is created.
profile_arg_value = os.getenv('HOME') + '/snap/firefox/common/.mozilla/firefox/WHATEVER_NAME_OF_THE_USER_PROFILE'
options.add_argument(profile_arg_param)
options.add_argument(profile_arg_value)
# Start an instance of the Firefox browser.
browser = webdriver.Firefox(service=Service(GeckoDriverManager().install()), options=options)
# Load URL
url = "about:profiles"
browser.get(url)
# Sleep, close browser and exit.
time.sleep(10) ;# This should give you enough time to look at the user profile used by the browser.
browser.close()
exit()
I might be missing something in the execution. Any help would be greatly appreciated!
Install: Caius
https://github.com/tobijk/caius.git
Download: Selenium Server
https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.9.0/selenium-server-4.9.1.jar
Execute: Server Start
Execute: Client Start
Log: Server