# HG changeset patch # User Robert McIntyre # Date 1319546016 25200 # Node ID d09937a6cb4bdc49d850ec82f089d6036957e387 # Parent 73beed20f7ded8af9fd38cf7e44940ae79333399 trying to build something to automatically refresh the browser. diff -r 73beed20f7de -r d09937a6cb4b auto-weave.pl --- a/auto-weave.pl Tue Oct 25 01:08:31 2011 -0700 +++ b/auto-weave.pl Tue Oct 25 05:33:36 2011 -0700 @@ -13,22 +13,34 @@ $" = "\n"; print "@org_files\n"; +$ignore_next = 0; + foreach(@org_files){ # add watchers $inotify->watch ($_, IN_MODIFY, sub { - my $e = shift; - my $name = $e->fullname; - print "$name was modified\n" if $e->IN_MODIFY; - system ("weave $name"); - print ("$name\n"); - $path = `readlink -f $name`; - $path =~ s|/home/r/proj|http://aurellem.localhost|; - print ("$path\n"); - $path =~ s|org|html|g; - print ("$path\n"); - system ("firefox $path"); + print ("IGNORE : $ignore_next\n"); + # ok, for some reason this get's called exactly + # twice every time the file is saved from emacs. + # so ignore every other invocation. + if ($ignore_next) { + $ignore_next = 0; + return; + } + + my $e = shift; + my $name = $e->fullname; + print "$name was modified\n" if $e->IN_MODIFY; + $output = `weave $name`; + print ("$name\n"); + $path = `readlink -f $name`; + $path =~ s|/home/r/proj|http://aurellem.localhost|; + print ("$path\n"); + $path =~ s|org|html|g; + print ("$path\n"); + #system ("firefox $path"); + $ignore_next = 1; }); } diff -r 73beed20f7de -r d09937a6cb4b play-browser.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/play-browser.py Tue Oct 25 05:33:36 2011 -0700 @@ -0,0 +1,19 @@ +#!/usr/bin/env python + + +from selenium import webdriver +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 +import time + +# Create a new instance of the Firefox driver +#driver = webdriver.Firefox() + +driver = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.FIREFOX) + + +# go to the google home page +driver.get("http://tycho.usno.navy.mil/cgi-bin/timer.pl") + +# you HAVE to quit if you're reusing firefox sessions +driver.quit() diff -r 73beed20f7de -r d09937a6cb4b refresh-browser.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/refresh-browser.py Tue Oct 25 05:33:36 2011 -0700 @@ -0,0 +1,19 @@ +#!/usr/bin/env python + + +from selenium import webdriver +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 +import time + +# Create a new instance of the Firefox driver +#driver = webdriver.Firefox() + +driver = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.FIREFOX) + + +# go to the google home page +driver.get("http://tycho.usno.navy.mil/cgi-bin/timer.pl") + +# you HAVE to quit if you're reusing firefox sessions +driver.quit() diff -r 73beed20f7de -r d09937a6cb4b sample.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sample.py Tue Oct 25 05:33:36 2011 -0700 @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +from selenium import webdriver +from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.common.keys import Keys +import time + +browser = webdriver.Firefox() # Get local session of firefox +browser.get("http://www.yahoo.com") # Load page +assert "Yahoo!" in browser.title +elem = browser.find_element_by_name("p") # Find the query box +elem.send_keys("seleniumhq" + Keys.RETURN) +time.sleep(0.2) # Let the page load, will be added to the API +try: + browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]") +except NoSuchElementException: + assert 0, "can't find seleniumhq" +#browser.close()