I have few questions in Selenium WebDriver (Selenium2) :
My 1st question is, do I need a standalone .jar file for RemoteWebDriver?
My 2nd question is, if the standalone .jar file is needed, then how can I start this .jar file/Selenium Server from the WebDriver's Client side (just like in Selenium RC) using Python ?
I do know how to start the selenium server from command line locally. But I was wondering if WebDriver has any improvements from RC regarding starting the Server. I am also aware that there is no need of a Selenium Server (standalone .jar file) if WebDriver is used locally.
Yes standalone jar file need to be in running state, in order to run tests on remote machine using RemoteWebDriver.
To run the server, just use java -jar that probably you know already.
refer: http://code.google.com/p/selenium/wiki/RemoteWebDriver for more details.
Related
So I made a program that start a headless browser ( Chrome ) with Selenium in Python.
I have a CyberGhost VPN.
When I try to start my script with the VPN active, Selenium open a chrome windows, with "data" in the url but doesn't proceed further.
Otherwise, it works when I start the script with inactive VPN and turn the VPN on when selenium is running normally.
I don't understart what can be the problem ...
Thanks :)
VPN is handled at the OS level, before Selenium gets anywhere near. You can try to setup a config with CyberGhostVPN and run an exec command to start your connection. After that, then start Webdriver and it should be running over VPN. See here on Calling an external command from Python
It may also be due to a firewall issue, so you can also try to deactivate the included firewall in CyberGhostVPN.
I have up and running an Apache Server with Python 3.x installed already on it. Right now I am trying to run ON the server a little python program (let's say filename.py). But this python program uses the webdriver for Chrome from Selenium. Also it uses sleep from time (but I think this comes by default, so I figure it won't be a problem)
from selenium import webdriver
When I code this program for the first time on my computer, not only I had to write the line of code above but also to manually download the webdriver for Chrome and paste it on /usr/local/bin. Here is the link to the file in case you wonder: Webdriver for Chorme
Anyway, I do not know what the equivalences are to configure this on my server. Do you have any idea how to do it? Or any concepts I could learn related to installing packages on an Apache Server?
Simple solution:
You don't need to install the driver in usr/local/bin. You can have the .exe anywhere and you can specify that with an executable path, see here for an example.
Solution for running on a server
If you have python installed on the server, ideally >3.4 which comes with pip as default. Then install ChromeDriver on a standalone server, follow the instructions here
Note that, Selenium always need an instance of a browser to control.
Luckily, there are browsers out there that aren't that heavy as the usual browsers you know. You don't have to open IE / Firefox / Chrome / Opera. You can use HtmlUnitDriver which controls HTMLUnit - a headless Java browser that does not have any UI. Or a PhantomJsDriver which drives PhantomJS - another headless browser running on WebKit.
Those headless browsers are much less memory-heavy, usually are faster (since they don't have to render anything), they don't require a graphical interface to be available for the computer they run at and are therefore easily usable server-side.
Sample code of headless setup
op = webdriver.ChromeOptions()
op.add_argument('headless')
driver = webdriver.Chrome(options=op)
It's also worth reading on running Selenium RC, see here on that.
I'm trying to run a Selenium Script (Using PHP) using a Webserver.
I'm working on Kali and to simulate the Webserver I use Xampp.
I tried to run the selenium script on Xampp by the following steps:
-Download the Php Webdriver Bindings, put them in the folder 'htdpcs' of xampp and edit the 'example.php' file following the settings of my own device.
-Download and execute the Selenium Server Standalone, on port :4444.
In the end, I download the geckodriver and I execute the file, but I got the this error:
OSError: [Errno 98] Address already in use
How to fix it in order to run the php-selenium script?
The Selenium Server will fork a geckodriver as soon as it needs one to start a new browser session. You should not start a geckodriver yourself. If you want to use its Webdriver API yourself you can start it with the --webdriver-port argument.
I've write a script in python for a bot that run using selenium, untill now I used the normal selenium webdriver, but now I want to move to Selenium Standalone server.
I have 2 servers on DigitalOcean, I want to use one server as the selenium standalone server and the other for send the requests.
In the Main server I run java -jar ~/selenium/selenium-server-standalone-3.14.0.jar for run the Selenium server, and it works.
In the second I have my scripts but I can't figure out how to allow the connection.
My options for run the webdriver are:
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('user-data-dir=/var/www/users/'+ Setup.db +'/cookies')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--lang=en')
chrome_options.add_argument('CHROME')
browser = webdriver.Remote(command_executor='http://MAIN_SERVER_IP:4444/wd/hub', desired_capabilities=DesiredCapabilities.CHROME)
But I can't run the webriver, I see that the 2 servers are "talking" beacause when I try to run the script, in the main server I read Only local connections are allowed. so that mean that there are some problem with the firewall or the settings but I don't know what to do.
The installation page here says to add the selenium server standalone jar to the CLASSPATH. What does the jar do? Do I need it? I ran some selenium code already and it works without it. I just instantiated IE doing
driver = driver.Ie()
I am running webdriver (selenium 2) in Python, trying to test IE9 (and then after test IE8). (I'm not using .NET, just running a .py file) Thanks!
That was the jar you needed to run with "Selenium 1". It is not necessary with Selenium 2 as far as I know. It may be used when doing remote testing (I haven't done that with Selenium 2), but it is definitely not needed for local testing.