Forum Discussion

nramesh's avatar
nramesh
Occasional Contributor
11 years ago

Guidance on VB automation scripting

My Web based application is undergoing an automation testing phase. How can i counter writing scripts in VB for the following scenario.The application will have 3 webpages A,B & C that run sequentially one after the other. However the page B gets loaded/appears only during  certain circumstances. Under this condition, how will my approach be to write a single VB script having both the below applicable conditions:



After Page A -> If Page B exists -> then proceed to Page C

and

After Page A ->  If Page B doesnot exist -> contiue and proceed to Page C



I was wondering if the event handlers tab would work for the above criterion? Would appreciate it if i can get guidance on the approach to be taken with an script structure  for the above coding.



Thank you in advance! 
  • I think it would be more like this... again, Pseudocode



    PageA.ClickLink()

    if (application.waitAliasChild("PageB", 3000).Exists then

        PageB.ClickRadio()

    PageC.DoAction;




    Essentially, all you need to do is through in a check after you click the link on PageA to see if PageB comes up within a specified period fo time.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I think it would be more like this... again, Pseudocode



    PageA.ClickLink()

    if (application.waitAliasChild("PageB", 3000).Exists then

        PageB.ClickRadio()

    PageC.DoAction;




    Essentially, all you need to do is through in a check after you click the link on PageA to see if PageB comes up within a specified period fo time.
  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor


    Hi Navaneeth



    I'm not entirely sure I understand exactly what it is you require here.  I'm assuming that once on Page A, something happens there, say a checkbox is checked or un-checked and this determines whether Page B is displayed next or not.  So, let's say that if the checkbox is ticked, Page B should be displayed, otherwise display Page C.



    Assuming the above is correct, your could use script logic along the lines of:





    'assumes Page A is currently displayed

    if (checkboxCtrl.checked) 'should display Page b next

       if (application.waitAliasChild("pageB", 3000).Exists)

          Log.message("Page B correctly displayed.")

       else

          (Log.warning("Page B was not displayed.")

       end if

    else 'Page c should be displayed

       if (application.waitAliasChild("pageC", 3000).Exists)

         Log.message("Page B correctly skipped and Page C displayed.")

       else

          (Log.warning("Page C was not displayed.")

       end if

    end if



    The above is more pseudocode than actual VBScript, but it's more about the required logic, assuming I've understood your initial query.  Hopefully it helps anyway.



    Regards

    Stephen.


  • nramesh's avatar
    nramesh
    Occasional Contributor
    Hi Stephen,



    There are no check boxes in Page A. It  only has a link button. So the structure goes as follows:



    Click on the link in Page A - > Page B with radio buttons appears  (perform action) -> directs to page C



    Click on the link in Page A -> Page B will not appear -> proceeds to Page C (directly from page A)  



    Will this require a seperate approach?
  • nramesh's avatar
    nramesh
    Occasional Contributor


    Thnank you Mr.Robert. Would this be the right approach for my script then? is the syntax right?



    form.linkACB.Click



    page.Wait



    if (form.fieldsetHellopage.waitAliasChild("radiobuttonStartNewApplication",3000).Exists Then



    form.fieldsetHellopage.radiobuttonStartANewApplication.ClickButton



    Set imageButton = form.imagebuttonButtonNext1



    Call imageButton.Click



    page.Wait



    Else



    Call



    Objects.cell.Check(Aliases.browser.pageXYZ.formForm1.tableErrmsgimg.cell)



    End If


  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Without knowing the full context of your application, I can't say definitively but that appears to be correct.