Service Virtualization

  • 1.  Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Posted Jul 20, 2016 09:10 AM

    I have recorded my workflow using Selenium Builder and executing it in CA DevTest but the browser is not opening in maximized mode.So is there any way by which we can set size of Browser.

     

     

    Also is there any way to scroll down in the WebPage.

    Attachment(s)

    zip
    objects.txt.zip   12 KB 1 version
    zip
    err.txt.zip   868 B 1 version


  • 2.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Broadcom Employee
    Posted Jul 20, 2016 10:18 AM

    You could trying adding a Script step in your testcase where resizing is required



    here are the steps

    Add a JSR-223 step before the step that require Resizing. 

    add the following code in the step (as an example)

     

     

     

    import org.openqa.selenium.JavascriptExecutor;

    JavascriptExecutor jse =
    testExec.getStateValue("WebDriver_");

    jse.executeScript("selenium.windowMaximize();");



    This is just a sample. 

     

     

    Thanks

     

     

    Shiney Abraham

    Sr Support Engineer



  • 3.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Posted Jul 21, 2016 01:23 AM

    Hi Abraham,

     

    I tried to use the above mentioned command but i am getting a null pointer exception error (attached in the comment).

    It seems WebDriver_ object is not getting recognised by CA Devtest.

     

    Also please find attached the list of available objects in CA DevTest in which I could not find WebDriver_.I also tried to put _WebDriver or _webDriver but that also didn't work.



  • 4.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Broadcom Employee
    Posted Jul 21, 2016 02:33 PM

    Can you try  this instead

     

    testExec.getStateValue("Web_Driver");



  • 5.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Posted Jul 22, 2016 06:57 AM

    Hi Abraham,

     

    Unfortunately testExec.getStateValue("Web_Driver"); is also not working.Can you please suggest any other way or if you can please check and tell the exact name of webdriver object.That would help a lot.

     

    Thanks



  • 6.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Broadcom Employee
    Posted Jul 22, 2016 12:09 PM

    Ragini,  I think this is what you need.  "  You would first  get the browser object :testExec.getStateObject("selenium.testrun") , then use the maximize script. 

     

    Here is the code to set it to max in DEVTEST:

     

    import org.openqa.selenium.remote.RemoteWebDriver;

    import org.openqa.selenium.Dimension;

     

    RemoteWebDriver driver = testExec.getStateObject("selenium.testrun").getDriver();

    driver.getDriver().manage().window().maximize();

     

     

     

    Now to set to specific size, add this to JSON before you import the script to DevTest.

     

       {

        "type": "setWindowSize",

         "width": "1500",

        "height": "1200"

        },

     

     

     

    But if you really want to set to specific size via script code, not JSON, here should be the way.

     

    import org.openqa.selenium.Dimension;

     

    Dimension d = new
    Dimension(1500, 1200);

    RemoteWebDriver driver =
    testExec.getStateObject("selenium.testrun").getDriver();

    driver().manage().window().setSize(d);

     

     



  • 7.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Posted Jul 25, 2016 02:29 AM

    Hi,

     

    I tried the above code and I am getting the below mentioned error.

    It seems that there is no method “getDriver()” found for class'org.openqa.selenium.chrome.ChromeDriver'.

     

     

    ============================================================================

    | Error in Script

    ============================================================================

    | Step:        Execute script (JSR-223)

    ----------------------------------------------------------------------------

    | Message:     bsh.EvalError: Sourced file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' : Error in method invocation: Method getDriver() not found in class'org.openqa.selenium.chrome.ChromeDriver' : at Line: 5 : in file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.D . . . '' : driver .getDriver ( )

    in inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' at line number 5

    ----------------------------------------------------------------------------

    | Trapped Exception: bsh.EvalError: Sourced file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.D . . . '' : Error in method invocation: Method getDriver() not found in class'org.openqa.selenium.chrome.ChromeDriver' : at Line: 5 : in file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' : driver .getDriver ( )

    in inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' at line number 5

    | Trapped Message:   javax.script.ScriptException: bsh.EvalError: Sourced file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.D . . . '' : Error in method invocation: Method getDriver() not found in class'org.openqa.selenium.chrome.ChromeDriver' : at Line: 5 : in file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.D . . . '' : driver .getDriver ( )

    in inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' at line number 5

    ----------------------------------------------------------------------------

    STACK TRACE

    1. javax.script.ScriptException: bsh.EvalError: Sourced file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' : Error in method invocation: Method getDriver() not found in class'org.openqa.selenium.chrome.ChromeDriver' : at Line: 5 : in file: inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.D . . . '' : driver .getDriver ( )

    in inline evaluation of: ``import org.openqa.selenium.remote.RemoteWebDriver;  import org.openqa.selenium.D . . . '' at line number 5

    at bsh.BshScriptEngine.evalSource(BshScriptEngine.java:102)

    at bsh.BshScriptEngine.eval(BshScriptEngine.java:61)

    at javax.script.AbstractScriptEngine.eval(Unknown Source)

    at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:669)

    at com.itko.lisa.test.ScriptExecHandler.executeScript(ScriptExecHandler.java:426)

    at com.itko.lisa.test.UserScriptNode._execute(UserScriptNode.java:202)

    at com.itko.lisa.test.UserScriptNode.execute(UserScriptNode.java:172)

    at com.itko.lisa.test.TestNode.executeNode(TestNode.java:981)

    at com.itko.lisa.test.TestCase.execute(TestCase.java:1280)

    at com.itko.lisa.test.TestCase.execute(TestCase.java:1195)

    at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1180)

    at com.itko.lisa.editor.WalkThruPanel.prepAndExecNode(WalkThruPanel.java:1048)

    at com.itko.lisa.editor.WalkThruPanel.access$900(WalkThruPanel.java:68)

    at com.itko.lisa.editor.WalkThruPanel$10.doCallback(WalkThruPanel.java:961)

    at com.itko.util.swing.panels.ProcessingDialog$2.run(ProcessingDialog.java:194)

    at java.lang.Thread.run(Unknown Source)

     

    Thanks

    Ragini



  • 8.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?
    Best Answer

    Broadcom Employee
    Posted Jul 25, 2016 11:52 AM

    Sorry there was a typo...

     

    driver.getDriver().manage().window().maximize();

     

    This is the correct code.

    To set to max, it is

    RemoteWebDriver driver =
    testExec.getStateObject("selenium.testrun").getDriver();

                                 driver.manage().window().maximize();



  • 9.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Posted Jul 26, 2016 05:32 AM

    Hi Abraham,

     

    It worked now.Thanks a lot for your help....:)



  • 10.  Re: Is there any way to resize the window of any Browser when triggering Selenium Builder Script?

    Posted Jan 31, 2017 04:51 AM

    Hi Abraham,

     

    I tried the same. this was working on 8.4 version of DevTest. But not we have upgraded to 9.5. and the same step is failing with the error that getDriver class is not found.

     

    Thanks & Regards,

    Mohan