3

I'm getting really confused with python and selenium. I've set up both chrome and Phantomjs with selenium on mac and it's working ok.

However, I can only run phantomjs as headless, and it's getting really frustrating having to code things twice (for phantom and chrome), just so I can see what is happening. Especially, since they work quite differently.

From what I understand there are these two things:

Docker selenium - https://github.com/elgalu/docker-selenium

This allows headless firefox and chrome, using VNC to see what is happening.

Selenium Grid Extension - https://github.com/zalando/zalenium

This allows parallel execution. However, I'm wondering do I really need this, since I wrote my parallel execution routine already in unittest?

From previous research my understanding is that selenium grid doesnt really work for Python (its java based)

If anyone can set me straight on what to use that would be great.

I'm thinking to just use the chrome headless and hopefully I will still be able to do my parallel execution in unittest

Ke.
  • 2,484
  • 8
  • 40
  • 78

1 Answers1

1

You're mixing a bunch of things, let's clarify:

  • PhantomJS is a headless browser that uses the WebKit rendering engine (not exactly like Chrome) and it can't run with UI.
  • You don't need to code twice, you can get the browser name from a config file and work with the interface webdriver to create whichever browser you want.
  • If you want to run specifically Chrome headless, try this, though AFAIK it's in beta stages and only on Linux.
  • Running in parallel can be achieved in multiple ways (docker, grid, a test framework, etc...). Depending on your case, you should choose what suits you. In your case I think docker and a grid is an overhead and you should continue using unittest: 1. Docker does let you run Chrome with a virtual display (sort of headless), but it's specialty is in scaling fast which I assume you don't need. 2. Selenium Grid mostly used for browser, OS matrix. It doesn't matter that it's Java based because it's a standalone server you connect to using remotewebdriver in whatever language.

So I hope it's

set you straight

;)

Moshisho
  • 2,781
  • 1
  • 23
  • 39
  • Seriously did set me straight my friend - thanks so much. Not sure about the coding twice bit, because what's happening for me (when I set proxies and some other things) is that specific code that is relevant to the driver being used is necessary, especially with error checking. Also, firefox has some bugs and isn't raising errors as it should be (whereas chrome does), so I have to create a bunch of workarounds for this. It's wasting a lot of time for me at the mo, so I think I will try with docker/grid/chrome headless first and then if that doesn't work, go onto your chromium suggestion. – Ke. Mar 15 '17 at 20:00
  • 1
    NP! I'm not sure how to do it in python, but you can check in runtime which browser you're running with even when working with the interface.. in C# it'll be something like `if (typeof(driver)==typeof(FirefoxDriver)) then handleSpecificError()`. – Moshisho Mar 16 '17 at 10:24
  • 1
    This is really cool, you're a gem Moshisho. This is saving me so much time. Hope you have a great day :) – Ke. Mar 16 '17 at 22:03
  • Thanks mate! You too ;) – Moshisho Mar 17 '17 at 11:20