1

I am using selenium. I have the following code:

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get("http://www.mysite.com")
x = browser.find_elements_by_xpath("//div[@id='containeriso3']/div/a[1]")
hrefs = [i.get_attribute('href') for i in x]

Now, this works.

But I want to do this is on a server which runs on ubuntu command line. This means I cannot use this

browser = webdriver.Firefox()

in my code. What alternative can be used to this through command line?

3 Answers 3

4

You can use HtmlUnitDriver which is headless browser based on Rhino javascript engine.

http://code.google.com/p/selenium/wiki/HtmlUnitDriver

Sign up to request clarification or add additional context in comments.

1 Comment

Can you please mention chat changes need to be brought to my code? Also, will it work with python?
1

If your Ubuntu server and your desktop are on the same network use Selenium Grid. Your code will start on the Linux server and your tests will be executed on your desktop.

Take a look at the following link:

http://code.google.com/p/selenium/wiki/Grid2

The examples are in Java but I'm sure you can adapt them to Python or at least get the idea of what you need to do.

1 Comment

They are not on the same server. The project is hosted on Amazon AWS.
0

I think you can also try to use ghost driver that is based on phantomjs:

https://github.com/detro/ghostdriver, or you can also try to run usual firefox driver on Xvfb.

It depends on what you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.