0

On Ubuntu 14.04, I need to start a headless instance of chromium and navigate to a page (no HTML, merely Javascript) that waits messages from a peer (a Websocket server relays the messages). On message reception of a relayed message from the peer, this headless client will run some javascript logic.

So I need this headless chromium to be running all the time my machine is up. I may refresh the page to reset it's state, but this is it.

I was able to start a headless chromium using Xvfb, I am just wondering if using this wrapper won't give more flexibility, in case I want to actually script some actions.

I know I know, Selenium is meant for automating test suites, but is there a way to use xvfbwrapper+selenium for bringing up a headless client page? how?

My problem is that this will return as soon as the page is loaded ... and then my script ends

driver.get("http://somedomain/url")

I want my headless chromium to remain up until I decide to kill the script.

I may implement a loop, but I am trying to figure out a smart way that won't peg the CPU.

Community
  • 1
  • 1
zabumba
  • 12,172
  • 16
  • 72
  • 129
  • 1
    Of course it returns, how else can you run other selenium commands? Just because it returns doesn't mean the browser isn't open. In fact, it means the opposite -- if it returns, rather than throwing an exception, the browser is open and ready for you to send it commands. – Bryan Oakley Apr 18 '16 at 12:10
  • Why do you need this javascript to run in a browser? Can't you just run a javascriipt interpreter without xvfb and selenium? – Bryan Oakley Apr 18 '16 at 12:11
  • I realize that. I hope the question doesn't cause frustration. We can't be all that smart or we wouldn't need the StackExchange right? ;) Yes it needs to be in a browser, I need a headless chromium engine. – zabumba Apr 18 '16 at 12:16
  • So, if it needs to be in a browser, and you know how to open a browser in a headless environment with selenium, what's the problem? – Bryan Oakley Apr 18 '16 at 12:22

1 Answers1

0

Found my answer here

user_choice = raw_input('Please click ENTER button to close application')
if not user_choice:
    print "ABORTED"
    quit()

or

 while True:
    time.sleep(1)
Community
  • 1
  • 1
zabumba
  • 12,172
  • 16
  • 72
  • 129