Install browsers in alpine container - selenium

How can I install google chrome and firefox in alpine container for running selenium testcases ?
I need to download it using Dockefile ? I tried it using below command but selenium testcases are not identifying it. Is there some chrome alpine image in docker hub ?
apk add chromium

Related

can we deploy jmeter in kubernetes with selenium integration?

I have deployed jmeter in kubernetes by using
https://github.com/kubernauts/jmeter-kubernetes
But I am facing difficulties when I want to integrate selenium webdriver with jmeter in kubernetes. I see there is no official documentation to deploy in distribute environment like in kubernetes. I just want to know is it possible to deploy jmeter with webdriver in kubernetes?
Why not? It's just a matter of installing WebDriver Sampler Plugin
Looking into the repository you provided I can see that all the "magic" of JMeter Plugins installation is being performed in Dockerfile-base so you need to just add a line like:
RUN cd /jmeter/apache-jmeter-$JMETER_VERSION/ && wget -q -O /tmp/jpgc-webdriver-3.3.zip https://jmeter-plugins.org/files/packages/jpgc-webdriver-3.3.zip && unzip -n /tmp/jpgc-webdriver-3.3.zip && rm /tmp/jpgc-webdriver-3.3.zip
into the Dockerfile

How to use Webdriver manager in Robot Framework?

In selenium I used webdriver manager through a command:
driver = webdriver.Chrome(Chromedrivermanager().install())
Is there a webdriver manager use for the robot framework? I would like the webdriver manager to download automatically when running the test script without additional interference.
My solution for using this with Robot Framework was with a python library that I called chromedriversync.
chromedriversync.py:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
def get_chromedriver_path():
driver_path = ChromeDriverManager().install()
print(driver_path)
return driver_path
Then, in my robotframework tests, I add
Library chromedriversync.py
${chromedriver_path}= chromedriversync.Get Chromedriver Path
Create Webdriver chrome executable_path=${chromedriver_path}
Go to www.google.com
I just use the chromedrivermanager install method's returned path variable, to supply to the Open Browser Robot Framework keyword.
The only thing that i found in internet is that Youn need to install webdrivermanager with command :
pip install webdrivermanager
and you launch this command before your script:
webdrivermanager chrome
robot --outputdir ./results/Robot-results ./TestSuits/*
NB: your browser (Chrome) has to be updated too : (Ubuntu)
sudo apt-get update
sudo apt-get install google-chrome-stable
There are two web driver managers as shown below,
If you use this one, you need to do one additional step on the command line, you cannot proceed with the test code unless you execute the below command, as this is part of the webdrivermanager setup.
webdrivermanager -
webdrivermanager 0.7.4
command-line step -
webdrivermanager chrome:2.38 firefox opera:v.2.35
webdriver-manager 2.3.0
You need to do the following to use webdriver-manager, did you notice something, there is nothing which needs to be done anything specific to webdriver-manager, BEAUTY of making use of robotframework. nice!!!
code
1. pip install webdriver-manager robotframework robotframework-seleniumlibrary
(prjenv) 09:37 PM##~::>pip list
Package Version
------------------------------ ----------
certifi 2018.11.29
chardet 3.0.4
colorama 0.4.1
configparser 4.0.2
crayons 0.3.0
idna 2.8
pip 19.2.3
requests 2.22.0
robotframework 3.1.2
robotframework-seleniumlibrary 4.1.0
selenium 3.141.0
setuptools 40.8.0
urllib3 1.25.6
webdriver-manager 2.2.0
wheel 0.32.3
2. create a file sample.robot
***Settings***
Library SeleniumLibrary
***Test Cases***
Sample Webdriver
[Tags] wd0
[Documentation] Sample invocation using WD
Open Browser http://google.com ff
Close All Browsers
3. execute the file as follows
robot *.robot
Output
========
(prjenv) 09:38 PM##~::>robot *.robot
==============================================================================
Sam
==============================================================================
Sample Webdriver :: Sample invocation using WD | PASS |
------------------------------------------------------------------------------
Sam | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: /Users/apachemain/output.xml
Log: /Users/apachemain/log.html
Report: /Users/apachemain/report.html
THAT'S IT!!!
in the cmd terminal
pip install webdrivermanager
webdrivermanager firefox chrome --linkpath /usr/yourdir
as for automatic updates you could make a batch file .bat (just cmd input) with the last command (it will update the version automatically) and set it to a windows scheduler
https://www.windowscentral.com/how-create-and-run-batch-file-windows-10
https://www.digitalcitizen.life/how-create-task-basic-task-wizard

Error running headless Chromium on Ubuntu

I installed Chromium 59.0, and I'm trying to run it in headless mode using the following command:
sudo /opt/google/chrome/chrome --headless --disable-gpu --no-sandbox
but I'm getting the following errors:
[0512/174717.638937:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[0512/174717.639027:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
Has anyone encountered this and found a way to get past it?
I encountered the exact same thing under dockerized ubuntu running karma.js tests.
You will need to have pulseaudio or similar running.
Try:
apt-get install pulseaudio
And before you run chrome
pulseaudio --daemonize
You can see it in my docker-entrypoint.sh:
https://github.com/codeclou/docker-nodejs-chrome-xvfb
When running with docker you will need to run docker with:
--shm-size=128M
Since chrome will complain about small /dev/shm which is 64MB by default.

chrome not reachable on travis ci

I am trying to use chrome standalone driver on Travis CI server. I am getting this error:
selenium.common.exceptions.WebDriverException: Message: u'chrome not reachable\
The script runs fine locally.
in .travis.yml I have
before_script:
# google chrome standalone driver
- wget http://chromedriver.storage.googleapis.com/2.10/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- sudo mv chromedriver /usr/local/bin
- sudo chmod a+x /usr/local/bin/chromedriver
and in my tests I have
from selenium.webdriver import Chrome
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
Chrome()
and after a delay I get the error message stated above.
I have tried changing the location of the chrome driver, and explicitly pass the executable_path to Chrome, but no joy.
I've successfully run tests in Travis using headless Chrome.
I've used the following arguments to start chrome:
no-sandbox
no-default-browser-check
no-first-run
disable-default-apps
The no-sandbox argument was the one that bypassed the 'chrome not reachable' error.

Is it possible to run selenium scripts using google compute engine?

I would like to run my selenium scripts on the cloud/online/remotely. I have been advised google compute engine could allow this.
It would be appreciated if this could be confirmed and additional steps that will be needed to be given too.
Any other solutions suggested would be appreciated.
The only difference is that your GCE instance doesn't have a display, which is going to be an issue for your browser.
To address this, you'll want to run Selenium using a "Virtual Framebuffer". This is basically a "Fake display".
Here's how you set a Virtual Framebuffer up in Ubuntu:
sudo apt-get install xvfb
sudo Xvfb :10 -ac
Then, before starting your selenium script, just run:
export DISPLAY=:10