Hey there! any question in your mind? Ask It Now!.

Popular Categories





I am Working on Flex Automation, Please suggest me to Resolve below error.

+2 votes
290 views
asked in Software Testing by Niks
Started InternetExplorerDriver server (64-bit)

2.35.3.0

Listening on port 9771

Exception in thread "main" org.openqa.selenium.WebDriverException: JavaScript error (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 147 milliseconds

Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'

System info: host: 'A356D7DB7C4N6JK', ip: '136.55.156.65', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'

Session ID: 9f2bd1c5-7560-4385-8b19-fadad9e2151c

Driver info: org.openqa.selenium.ie.InternetExplorerDriver

Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=11, ie.usePerProcessProxy=false, cssSelectorsEnabled=true, ignoreProtectedModeSettings=true, requireWindowFocus=false, handlesAlerts=true, initialBrowserUrl=http://localhost:9771/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)

at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)

at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:508)

at CoreHoris.CoreFlexFunction.call(CoreFlexFunction.java:108)

at CoreHoris.CoreFlexFunction.FlexSetFocus(CoreFlexFunction.java:73)

at CoreHoris.CoreFlexFunction.FlexSetFocus(CoreFlexFunction.java:77)

at CoreHoris.HORISLaunch.main(HORISLaunch.java:31)
commented by Niks
reshown by Bhartesh
Email Id: Nikhil.Gawande39@gmail.com
Please share your email ID on my ID,  so that I can send you the compiled flex file.
commented by Niks
Above error got resolved and Next challange I am facing with flex automation is, How to access dynamic elements created through Action Script. Below is code snipet which is generating dynamic menus and adding it in container whose id is "menuHolder"

private function createMenu(value:ArrayCollection):void {
             
             app.menuHolder.removeAllChildren();
             
             var groupVOs:ArrayCollection = MainScreenUtil.getGroupVOs(value);
             
             var groupingMenuRenderers:Array = [];         
             for each (var data:Object in groupVOs) {
                 var groupingMenuRenderer:GroupingMenuRenderer = new GroupingMenuRenderer();
                 groupingMenuRenderer.label = data["groupCode"];
                 groupingMenuRenderer.labelField = "groupName";
                 groupingMenuRenderer.data = data;
                 groupingMenuRenderer.children = data["children"];
                 groupingMenuRenderers.push(groupingMenuRenderer);    
             }
             
             var groupingMenu:GroupingMenu = new GroupingMenu();
             groupingMenu.addEventListener(GroupingMenuEvent.MENU_CLICK, onMenuClick);
             groupingMenu.groupingMenuRenderers = groupingMenuRenderers;
             
             app.menuHolder.addChild(groupingMenu);
             /**    var spacer : Spacer = new Spacer();
              spacer.percentHeight = 100;
              app.menuHolder.addChild(spacer);*/
             
             if (groupVOs.length > 0) {
                 var vo : GroupVO= groupVOs.getItemAt(0) as GroupVO;            
                 if (vo.children && vo.children.length > 0) {
                     selectTarget(vo.children[0]);
                 } else {
                     selectTarget(vo);
                 }
             }

Please suggest me how to access them.
commented by Niks
Below is my Code:
class HORISLaunch
{
    public static void main(String args[]) throws InterruptedException
    {
       
        File file = new File("C:/swdtools/Selenium/Selenium-Internet Explorer Driver Server v2.35.3 (for 64 bit Windows IE)/IEDriverServer.exe");
        System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
       
        WebDriver driver = new InternetExplorerDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("C:/Users/43914827/Desktop/bin-debug/FlexAutomationTest.html");
       
        CoreFlexFunction flexDriver = new CoreFlexFunction(driver, "FlexAutomationTest");
        Thread.sleep(8000);
        flexDriver.click("btn11", "Hello");
    }
}



These are functions from User Extension

package CoreHoris;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class CoreFlexFunction {    
    private final WebDriver webDriver;
    private final String flashObjectId;    
    public CoreFlexFunction(final WebDriver webDriver, final String flashObjectId) {       
        this.webDriver = webDriver;
        this.flashObjectId = flashObjectId;
    }

    
     public String doFlexClickMenuBarUIComponent(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexClickMenuBarUIComponent", objectId, optionalButtonLabel);
   }

    public String doFlexClickMenuBarUIComponent(final String objectId) {
         return doFlexClickMenuBarUIComponent(objectId, "");
    }
    public String click(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexClick", objectId, optionalButtonLabel);
   }

    public String click(final String objectId) {
         return click(objectId, "");
    }
    public String ClickDataGridItem(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexClickDataGridItem", objectId, optionalButtonLabel);
   }

    public String ClickDataGridItem(final String objectId) {
         return click(objectId, "");
    }
    
    public String FlexClickDataGridUIComponent(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexClickDataGridUIComponent", objectId, optionalButtonLabel);
   }

    public String FlexClickDataGridUIComponent(final String objectId) {
         return FlexClickDataGridUIComponent(objectId, "");
    }
    
    public String FlexSelectComboByLabel(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexSelectComboByLabel", objectId, optionalButtonLabel);
   }

    public String doFlexSelectComboByLabel(final String objectId) {
         return click(objectId, "");
    }
    public String FlexSelect(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexSelect", objectId, optionalButtonLabel);
   }

    public String FlexSelect(final String objectId) {
         return FlexSelect(objectId, "");
    }
    public String FlexRefreshIDToolTips(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexRefreshIDToolTips", objectId, optionalButtonLabel);
   }

    public String FlexRefreshIDToolTips(final String objectId) {
         return FlexRefreshIDToolTips(objectId, "");
    }
    public String FlexDoubleClick(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexDoubleClick", objectId, optionalButtonLabel);
   }

    public String FlexDoubleClick(final String objectId) {
         return FlexDoubleClick(objectId, "");
    }
    public String FlexSetFocus(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexSetFocus", objectId, optionalButtonLabel);
   }

    public String FlexSetFocus(final String objectId) {
         return FlexSetFocus(objectId, "");
    }
    public String FlexMouseMove(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexMouseMove", objectId, optionalButtonLabel);
   }

    public String FlexMouseMove(final String objectId) {
         return FlexMouseMove(objectId, "");
    }
    public String FlexType(final String objectId, final String optionalButtonLabel) {       
        return call("doFlexType", objectId, optionalButtonLabel);
   }

    public String FlexType(final String objectId) {
         return FlexType(objectId, "");
    }
    
    public String getFlexDataFieldLabelForGridRow(
            String dataGridId, String field, int row) {
        return call("getFlexDataGridFieldLabelForGridRow", dataGridId, field, Integer.toString(row));
    }
    public int getFlexDataGridRowCount(String dataGridId ) {
        return Integer.parseInt(call("getFlexDataGridRowCount", dataGridId));
    }
    public int getSelectionIndex(String selectionFieldId) {
        return Integer.parseInt(call("getFlexSelectionIndex", selectionFieldId, ""));
    }

//... Omitted for clarity ...

    private String call(final String functionName, final String... args) {final Object result =
            ((JavascriptExecutor)webDriver).executeScript(
                 makeJsFunction(functionName, args),
                 new Object[0]);

         return result != null ? result.toString() : null;
    }

    private String makeJsFunction(final String functionName, final String... args) {
         final StringBuffer functionArgs = new StringBuffer();

        if (args.length > 0) {
            for (int i = 0; i < args.length; i++) {
                if (i > 0) {
                    functionArgs.append(",");
            }
                functionArgs.append(String.format("'%1$s'", args[i]));
         }
        }
        return String.format(
            "return document.%1$s.%2$s(%3$s);",
            flashObjectId,
            functionName,
            functionArgs);
    }


}

Please log in or register to answer this question.

Related Questions

Not a Member yet?

Ask to Folks Login

My Account
683 Folks are online
50 members and 633 guest online
Your feedback is highly appreciated