Disable web driver logs in Selenium Python - python

I wrote a script that uses Selenium with Python. When I run the script, it creates a log file in the script directory. When I use the Firefox driver, a geckodriver.log file is created.
Is there an option to set to disable this?

Related

Selenium Servers and Geckodriver don't run at same port

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.

python cannot run selenium tests in firefox but pytest can

I'm using pytest with selenium. I have a simple setup:
browser = webdriver.Firefox()
when running the test file with py.test test_foo.py
The firefox browser launched correctly, got the url and executed the test with no problem.
Then i created another python file testsuite1.py which contains
pytest.main('py.test test_foo.py')
I ran python testsuite1.py, it opens the Firefox browser but failed to get the URL and finish the test. The error that it failed on:
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
I googled many different posts on this issue and I couldn't find any solutions. I've updated to Selenium 2.47.1, using Firefox 40. I don't understand why it would work with py.test command and not pytest.main within python.
Any ideas?

How can I execute a python script at the same time another application begins running?

I'm still a novice to Python but I would like my python script to start running the moment I click on the Google Chrome icon to open up chrome. Is it possible for the script to start and run in response to other applications (such as Chrome) being used?
You could accomplish this via the command line:
Windows
C:\Users\path\to\python\script>start chrome & python script.py
OS X
$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome) & python ~/path/to/file/script.py
The & in the command allows you to open Google Chrome (or the web browser of your choosing) in the background while executing your Python script in the foreground.
Regarding Chrome specifically, you might also explore Google startup scripts, though it appears that you have to sign up for Google's Cloud services to implement these.

Cannot create browser process when using selenium from python on RHEL5

I'm trying to use selenium from python but I'm having a problem running it on a RHEL5.5 server. I don't seem to be able to really start firefox.
from selenium import webdriver
b = webdriver.Firefox()
On my laptop with ubuntu this works fine and it starts a brings up a firefox window. When I log in to the server with ssh I can run firefox from the command line and get it displayed on my laptop. It is clearly firefox from the server since it has the RHEL5.5 home page.
When I run the python script above on the server it (or run it in ipython) the script hangs at webdriver.Firefox()
I have also tried
from selenium import webdriver
fb = webdriver.FirefoxProfile()
fb.native_events_enabled=True
b=webdriver.Firefox(fb)
Which also hangs on the final line there.
I'm using python2.7 installed in /opt/python2.7. In installed selenium with /opt/python2.7/pip-2.7.
I can see the firefox process on the server with top and it is using a lot of CPU. I can also see from /proc/#/environ that the DISPLAY is set to localhost:10.0 which seems right.
How can I get a browser started with selenium on RHEL5.5? How can I figure out why Firefox is not starting?
It looks like the problem I'm encountering is this selenium bug:
http://code.google.com/p/selenium/issues/detail?id=2852
I used the fix described in comment #9 http://code.google.com/p/selenium/issues/detail?id=2852#c9
That worked for me.

Selenium Remote Web Driver: How to start the remote server from Client

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.

Categories