How to make Selenium use localhost proxy - firefox

I have a perl based selenium script with the following statement :
$sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*chrome",
browser_url => "https://$ARGV[0]/" );
This throws up the Firefox browser. I want that when the Firefox browser is thrown up it is configured to use my proxy namely 127.0.0.1:8080 where I have a proxy service already started. How can I accomplish this without making any changes to the above shown code?

For Firefox, you need to create a profile for Selenium. Start Firefox with -ProfileManager -no-remote to be able to select this profile. Configure it accordingly.
When starting Firefox with the Selenium webdriver, you can then specify the profile to use with webdriver.firefox.profile
I couldn't find a solution to achieve the same with the Perl API. You might have to hack the sources to be able to specify the profile. Just add -P plus the name of the profile to the command line options of the browser process.
Alternatively, you can insert a script in the path variable before you run the tests. For example, on Unix:
#!/bin/bash
/usr/bin/firefox -P selenium
Save this in, say, $HOME/selenium/bin/firefox, make this new file executable and:
export PATH="$HOME/selenium/bin/firefox;$PATH"
The tests will not think that the script is the firefox executable and run that. The script will then run Firefox with the correct parameters.

Related

Jmeter cannot find keytool application and no keystore was provided. Tried alll

Im working with Jmeter, trying to running it as a proxy, but when I start recording, I got this alert. I tried setting user.properties, but i can’t find a solution. Please, so grateful if you help me!
In order to be able to record HTTPS traffic JMeter generates special MITM certificate which needs to be installed in the browser
In order to be able to generate the certificate JMeter needs keytool command which normally lives in "bin" folder of JDK or JRE
So make sure to add the "bin" folder of your Java installation to your operating system PATH and it should resolve your issue.
Example command on Windows:
setx PATH=c:\java\bin;%PATH% && jmeter.bat
Example command on Unix and derivatives:
PATH=/opt/java/bin:$PATH && ./jmeter.sh
Replace c:\java or /opt/java with the real path to your JDK or JRE installation.
You should get something like:
if you launch JMeter from the same terminal window you will be able to start the HTTP(S) Test Script Recorder without any issues
Also be aware that there is an easier way of recording a JMeter test: JMeter Chrome Extension, in this case you won't have to worry about proxies and SSL certificates

Local browserstack serenity testing

I am trying to run a serenity test locally via browserstack. I have downloaded the following test repo: https://github.com/browserstack/serenity-browserstack
replaced my browserstack credentials and run the following command mvn clean verify -P local.
I am using the browserstack chrome extension on my mac but whenever i use the command nothing happens, there is no activity on the remote browser screen.
And when looking in browserstack Automate tab i see that a test has been run but the local is false...
what am i doing wrong?
To enable local testing BS Automate needs this capability as well as their BrowserStackLocal binary should be up and running before the test executes.
I see that their code starts the BrowserStackLocal binary programmatically (replacement of chrome extension) before test begins.
https://github.com/browserstack/serenity-browserstack/blob/master/src/test/java/com/browserstack/BrowserStackSerenityTest.java#L39
Do verify that the 'browserstack.local' capability is correctly set to 'True'. This should enable the local testing and use the binary connection which is being spawned by above code.
P.S : Chrome's BS local extension wont be used by BS Automate, it is used only by BS Live.

Unknown option: -Dwebdriver.chrome.driver when running selenium server standalone on Mac

I was trying to manually run selenium server standalone on MAC and then run my tests with intern-runner in Chrome browser. As I've been advised on intern User Guide:
"To use ChromeDriver and IEDriver with a Selenium server, the driver executable must either be placed somewhere in the environment PATH, or their locations must be given explicitly to the Selenium server using the -Dwebdriver.chrome.driver (ChromeDriver) and -Dwebdriver.ie.driver (IEDriver) flags upon starting the Selenium server."
I started the Selenium server and put path to chrome driver on my machine, but got error:
"Unknown option: -Dwebdriver.chrome.driver"
any idea on why seleinum unable to recognize the options?
Is there any other solution on how to run chrome webdriver/IE webDriver from command line with selenium standalone server?
Where the driver executable could be placed in the environment PATH on MAC?
I was able to run chrome driver separately with out any issues using:
./node_modules/.bin/chromedriver --port=4444 --url-base=wd/hub
For selenium3 you need to use Dwebdriver.chrome.driver option first.
java -Dwebdrive.chrome.driver=path_to_chrome_driver -jar selenium_server_file
To avoid any path issues better download both files in the same directory and run from there.
Example:
java -Dwebdrive.chrome.driver=chromedriver -jar selenium-server-standalone-3.0.1.jar
Also have Chrome browser installed.
Is drive instead of driver

running selenium test suites created by selenium ide (firefox) over command line (ubuntu)

I have the problem that my selenium tests created via the firefox plugin "Selenium IDE" won't work when executed over cli with htmlsuite command. The test should simply open google.de in firefox browser.
I can record and execute the test just fine in selenium ide, but when i execute the following command in cli:
java -jar /var/lib/jenkins/jobs/SuiteCRM_CI_Test/selenium-server-standalone-2.48.2.jar -debug -log /home/jenkins/wtflog.log -firoxProfileTemplate /var/lib/jenkins/jobs/SuiteCRM_CI_Test/firefox_profile -htmlSuite *firefox http://google.de /home/koschig/Arbeitsfläche/seleniumtests/googlesuite.html results.html
All that happens is, firefox will be opened with 2 tabs: one being the firstrun" tab and the other is the following:
chrome://src/content/TestRunner.html?auto=true&multiWindow=true&defaultLogLevel=info&baseUrl=http%3A%2F%2Fgoogle.de&resultsUrl=http://localhost:4444/selenium-server/postResults&test=http%3A%2F%2Flocalhost%3A4444%2Fselenium-server%2Ftests%2Fgooglesuite.html
which gets me an error, file not found
Well, I don't know where the first half of this url comes from, the second half is crafted with the parameters I wrote in the command line.
Does anyone know how to solve this problem? I expected that firefox will be opened and google.de will be accessed...

CentOS Selenium - Preparing firefox profile

I'm trying use to selenium with firefox on CentOS from command line like this:
java -jar selenium-server-standalone-2.19.0.jar -interactive
Then, I type:
cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
Then it stucks on "Preparing Firefox profile..." part and crashes:
13:59:13.105 INFO - Preparing Firefox profile... 13:59:33.366 ERROR -
Failed to start new browser session, shutdown browser and clear all
session data
Please help me solve this, I'm quite new to the unix world.
Thanks!
Are you pointing directly to the firefox executable, or are you pointing to an alias?
By default selenium should be pointing to your selenium binary, what is in /usr/bin is usually a script that interacts with the firefox executable.
you could define a specific firefox profile (you have to create it first):
java -jar selenium-server.jar -log SeleniumServer.log -firefoxProfileTemplate "PROFILEPATH" -interactive
And for those wondering, if you're at the command line, you can create a profile like this:
firefox -CreateProfile profilename

Resources