Can I use selenium webdriver on a non-gui server? (Python) - python

I want to use the selenium webdriver on a linux server running Ubuntu. How can I use selenium on said server without opening a browser, as it doesn't have one? I'm using Selenium with Python and Gecko(Firefox), but I'll be willing to switch to JavaScript or Chrome if I have to.

Related

How Can I Use Proxies For Selenium Python Firefox?

I want to use a proxy for selenium python using the firefox webdriver. I can assign firefox a proxy through the normal browser's GUI but I don't know how to do it Selenium Python. It uses port 8080 and it does not need authentication.

Selenium: How to work with already opened web application in Chrome

I'm looking for a solution that could help me out automating the already opened application in Chrome web browser using Selenium and Python web driver. The issue is that the application is super secured, and if it is opened in incognito mode as Selenium tries to do, it sends special code on my phone. This defeats the whole purpose. Can someone provide a hacky way or any other work around/open source tool to automate the application.
Selenium doesn't start Chrome in incognito mode, It just creates a new and fresh profile in the temp folder. You could force Selenium to use the default profile or you could launch Chrome with the debug port opened and the let Selenium connect to it. There is also a third way which is to preinstall the webdriver extension in Chrome. These are the only ways I've encountered to automate Chrome with Selenium.

How to use Safari Browser in Selenium Webdriver using Python bindings

I am not able to launch safari browser from Selenium web driver. I am using Python bindings.
Could not find any reference that provided detailed steps for Python.
I am aware there is a related question on stackoverflow, but it doesn't answer for python -
python selenium webdriver safari driver
Followed the Documentation on http://code.google.com/p/selenium/wiki/SafariDriver , downloaded and installed safari developer certificate. This doc has code for Java and not for python bindings.
Below is my code(I am using desired capabilities) Not sure what am I missing here -
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver
browser = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.SAFARI)
browser.get('http://www.google.com')
browser.close()
From the looks of it, you're trying to open a webpage with a webbrowser. Why not use "webbrowser"? It's easy to get the webbrowser have safari as default:
import webbrowser
browser = webbrowser.get('safari')
browser.open("http://www.google.com/")
As I can't selenium set up, I'm not sure if this is what you want. Who knows, it could be an alternative?

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.

Can't lauch selenium with a python script

I am trying to lauch a Selenium scrit from a Python script and it gets stuck at "11:16:32.144 INFO - Launching Firefox..."
The Selenium server is running well, I also tried the Selenium IDE and it works. I am using Ubuntu lynx, Firefox 3.6.23, Selenium server 2.11.0
What do you think it could be ?
Thank you very much.
Regards.
It could be that Selenium can't find firefox somehow?
Is the process ending? or just hanging?
Try starting selenium runner manually, say from ipython, something like:
from selenium import selenium
sr = selenium(host, port, "*firefox*", url)
sr.start()
and see if you get an exception?

Categories