Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem when testing with HtmlUnitDriver and FirefoxDriver

    Hi all,

    I'm trying now trying to add automated test to my Smartgwt application. I want to support both drivers HtmlUnitDriver (for nightly tests) and FirefoxDriver (for acceptance tests).

    Problem with FirefoxDriver:
    Here I get access to page elements using the following static method:

    Code:
    public class TestUtilities {
    	
    
    	public static By locate(final String locator) {
    		if (locator == null) {
    			throw new IllegalArgumentException(
    					"No elements with null id could be found");
    		}
    		return new By() {
    			@Override
    			public List<WebElement> findElements(SearchContext context) {
    				return Collections.<WebElement> emptyList();
    			}
    
    			@Override
    			public WebElement findElement(SearchContext context) {
    				JavascriptExecutor executor = (JavascriptExecutor) context;
    				return (WebElement) executor.executeScript(
    						"return AutoTest.getElement(arguments[0]);", locator);
    			}
    		};
    	}
    }
    I use the Selenium IDE on firefox (with smartgwt user-extensions.js/user-extensions-ide.js well added) to retrieve the path to specifics WebElement on a page.
    However the following path
    Code:
    "//ColumnTree[ID=\"Inventory\"]/column[Class=ListGrid||index=0||length=1||classIndex=0||classLength=1||roleIndex=0||roleLength=1||scRole=list]/body/row[1]/col[fieldName=treeField||0]"
    always points (when tests are executed ) to the first entry of a "com.smartgwt.client.widgets.grid.ColumnTree" although I got the path when clicking the second entry in the Selenium IDE.



    Problem with HtmlUnitDriver:

    Like you saw above the static method for getting reference on WebElements uses a javascript object provided by SmartGwt (namely the "AutoTest"). When trying to use this method with the HtmlUnitDriver I get the error saying that the AutoTest object cannot be found. That is why I would like to know how to append the AutoTest to the HtmlUnitDriver. I already tried to execute the file using the following without success:

    Code:
    driver.executeScript(".../AutoTest.js");
    Thanks for any help...
    Rod

    #2
    Hi!

    i forgot to mention that I found a workaround for the problem with FirefoxDriver. I just increments the row index in a ColumnTree that Selenium IDE gives to me.

    The problem with HtmlUnitDriver still remains.

    Thanks for any help
    Rod

    Comment

    Working...
    X