Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, April 8, 2012

Scripting Selenium / WebDriver with JavaScript

This is the example code I wanted to write using JavaScript:

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

Here is where I looked for help when it wouldn't work[1]:

http://stackoverflow.com/questions/10057163/cant-run-java-example-for-selenium-webdriver

To save you the trouble: my Java is poor.  :-)  That's okay, because I'm not a Java programmer.  I do want to script Java[2], however, using JavaScript and Mozilla Rhino.  A prime candidate for learning how to do so (for me) is writing Selenium / WebDriver tests against their Java API.

I finally got the example code to work.  Here is the command line:

alis-mac-pro:selenium ali$ java -cp ".:/Users/ali/Downloads/selenium-2.20.0/*:/Users/ali/Downloads/selenium-2.20.0/libs/*:/Users/ali/Downloads/rhino1_7R3/*" org.mozilla.javascript.tools.shell.Main -f example.js 
Page title is: Cheese! - Google Search

That's my input, and the program's output.  And here is the example.js file that Rhino executed:


importClass(org.openqa.selenium.By);
importClass(org.openqa.selenium.WebDriver);
importClass(org.openqa.selenium.WebElement);
importClass(org.openqa.selenium.htmlunit.HtmlUnitDriver);

// Create a new instance of the html unit driver
// Notice that the remainder of the code relies on the interface, 
// not the implementation.
var driver = new HtmlUnitDriver();

// And now use this to visit Google
driver.get("http://www.google.com");

// Find the text input element by its name
var element = driver.findElement(By.name("q"));

// Enter something to search for
element.sendKeys("Cheese!");

// Now submit the form. WebDriver will find the form for us from the element
element.submit();

// Check the title of the page
print("Page title is: " + driver.getTitle());




[1] - (BTW, before this, I asked for help on irc.freenode.net on #selenium and on #java and got nearly zero response.  The response was useful, though, but without any follow-up, I was left high and dry.  Theoretically, IRC and other live communication channels are wonderful resources for support, but I find that the reality falls way short of that theory.  Maybe it's just my theory?)

[2] - http://www.mozilla.org/rhino/ScriptingJava.html

Tuesday, July 13, 2010

SourceForge.net: globonote

GloboNote - Desktop note taking program

GloboNote is a simple and easy to use desktop note taking program(Sticky Note). It lets you organize your ideas, ToDOs, reminders in one place and allows you to find it easily. GloboNote can be run in any OS that has Java 6 installed.

List of Features:

  • Platform Independent. Run on any OS that has Java 6 or higher installed.
  • Set Alarms. Remind yourself of important events. Set recurring alarm, play custom sound(*.wav, *.aiff or *.mp3).
  • Build-in Calculator. Enter the calculation in the note then press F2.
  • Organize notes in group. Display/Hide notes according to group.
  • Customize notes. Change color, font, behavior of your note.
  • Create note templates and load it using hotkeys(ALT-1 to ALT-4).
  • Search Notes. Locate your notes using the search tool. Search while you are typing.
  • Attach files on note then double click to launch it.
  • Attach images on notes.
  • Paste image(screenshot) from clipboard to note.
  • Support for URLs handling. (Ctrl-)Click on the URL and the appropriate application will be launched.
  • Find/Replace the content of the note
  • Make note to always stay on top of other window.
  • Make note to auto rollup when not used.
  • Support for rich text editing with bold, italic, colour etc.
  • Restore deleted notes.
  • Lock note to prevent unintended editing or deletion of note
  • Export note as plain text
  • Print note

Detailed list of features...


Very handy! So far, I like it tons better than Mac Stickies.

Posted via email from Ali Nabavi's posterous