D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Website automation

 

On 22 May, 2013, at 6:04 pm, Simon Waters wrote:

Something I should know more about.

I was trying to persuade Firefox on Linux to run a Selenium-IDE test I
made from the command line.

The examples of using TestRunner.html to do this are all for Windows.

No one jumped up in #selenium and said "don't be daft".

So variations on:

iceweasel -chrome
'chrome://selenium-ide/content/selenium/TestRunner.html?test=file:///home/simon/Desktop/login-and-submit&auto=false&baseURL=http://example.com/'
-height 900 -width 900

It mostly starts Firefox/Iceweasel (10), sometimes does compatibility
check for addons, and then sits with no window open spawning the odd
process, and waiting for something interesting to happen.

Has anyone run such a test case from Linux command line (and ideally and pulled back a result). I note Mr Hudson is clearly interested in this sort
of thing.

I just need to automate a page with javascript in, nothing very clever,
need to login, click a few links, and wait 90 seconds, then check on
screen for a result. But I want eventually the run it under xvfb so it can be forgotten about till it fails, and Selenium looked like a relatively
well trodden path to try.

I do similar stuff for screenshots all the time, but then I just need to visit a page and run the javascript and snapshot the result, not interact
with it at all.

Though I'm familiar with Selenium, I don't know anything about Selenium-IDE, so I may not have grasped exactly what you're after, but if it is what I think, then yes, the mozrepl.sh bash function library I put on GitHub should let you drive any xulrunner-based browser such as Firefox/Iceweasel from a shell script, including loading URLs, querying for DOM nodes' states and submitting forms. You just need to install the MozREPL browser extension (and check that it starts and listens on the expected port). At least in theory. This would be a good stress test for the library and the whole bash-tempfile-expect- netcat-MozREPL-xulrunner chain. I would not be surprised if it turned out to exhibit a certain fragility under load. :-)

My use case for first finding and then hacking on the library was automatically switching on/off proxies as part of a do-it-all "switch- to-mobile-mode" script, and that is indeed working: I now run the script and as well as all the other stuff like unmounting LAN shares, turning on WiFi, switching on DHCP, swapping ssh config file, etc it now successfully tells my browser to stop routing through my proxy server (change session pref 'network.proxy.type'). I already had my `screen' and shell sessions updating their env vars; just emacs and its various sub-apps (identica, packages, web, IRC, etc) to go now, and I won't have to quit/logout/relaunch anything when I go mobile, leaving all my tabs and buffers and other state intact.

Otherwise, have you considered GreaseMonkey, or whatever it's called now? Not sure if it fits the bill.

--
Phil Hudson                  http://hudson-it.no-ip.biz
@UWascalWabbit                 PGP/GnuPG ID: 0x887DCA63


--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq