18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Recording for Dynamically changing "Div Id"

AkshadaAkshada Members
edited April 2011 in Sahi - Open Source
Hi Narayan,

I am recording a script in Java for my application.
My application creates graphs. On clicking on any graph i get to see the list of data for the graph.

The graph gets created everytime with diffrerent "div Id" Eg: browser.div("9-bodygraphDiv").click();
Now this "9" will change the next time and increment to 10, when i create a new graph on playback.
My script would fail as the new graph would have 10-bodygraphDiv" and so on.

Also i have seen the "Alternatives" but they too are some DivId's.
Any suggestion would be great!!

Is there something else i could do?? Can I use "browser.area"?? How???

Thanking in Advance!!!

Regards
Akshada

Comments

  • wgoriswgoris Members
    Hi,

    You could use a regular expression: browser.div(/\d*-bodygraphDiv/).click();
    This wil match browser.div("9-bodygraphDiv").click(); browser.div(10-bodygraphDiv").click(); ...
  • Hi wgoris,

    Thanks for ur reply!!! :)

    But there is a problem....
    My Dashboard contains say 5 graphs for instance.
    Out of which the Reg-ex matches all 5.
    So now which graph it will click???
    Is there some method where i'll get how many elements (Regex condition ) is matching so that i can tell it to click on "2nd Element/Graph" or so....

    Thanks again for the Help!!

    Regards
    Akshada
  • wgoriswgoris Members
    Perhaps you can get the right div by using his dom or positional relation?
    You can find more info here: http://sahi.co.in/w/all-apis
  • AkshadaAkshada Members
    edited April 2011
    Hi,

    Hi,

    Yea i am trying that too....
    But it is somehow not returning the "Div-Id" for the dynamic element....
    I dnt know the exact steps too....:(

    Thank you for the help :)

    Regards,
    Akshada
  • Hi,

    I used .near, .in but it doesnt work....
    I also used .bySeleniumlocator but it ain't working :(
    Wat else can be used???

    Regards,
    Akshada
  • Narayan,
    I am getting problem with dynamic id. Here id's are keep changing every time. so while running the scripts it is not identifying the exact location. so does we have any alternate option to run the scripts.
    Please find the attached script

    Original script:

    _setValue(_textbox("PortletHandler\$Portlet29\$PartNumTextBox"), "testwds23");

    $Portlet29 will automatically increased to next number

    I am trying like this way:

    var $temp = "PortletHandler" + "\\$portlet" + $i + "\\$TransTypeDropdown";
    _alert($temp);
    //var $test = $temp;
    //_setSelected(_select($test), "INSPECTION");
    _setValue(_textbox("PortletHandler" + "\\$portlet".replace('\','') + $i + "\\$PartNumTextBox".replace('\','')), "testwds23");
    _setSelected(_select("PortletHandler" + "\\$portlet".replace('\','') + $i + "\\$TransTypeDropdown".replace('\','')), "INSPECTION");

    for above scenario i am getting problem with escape characters
    does we have silverlight support?
    Please help me here.
    Thanks,
    Chandu
  • narayannarayan Administrators
    Akshada,

    Use
    browser.div("/bodygraphDiv/[0]").click();
    through
    browser.div("/bodygraphDiv/[5]").click();
    to click on the various graphs.

    Chandu,

    Use,

    _setValue(_textbox("PortletHandler$Portlet" + $i + "$PartNumTextBox"), "testwds23");


    If the $i is not determinable at this point, and only one portlet is available at any time, you can replace the number with a regular expression.

    _setValue(_textbox("/PortletHandler[$]Portlet.*[$]PartNumTextBox/"), "testwds23");

    Regards,
    Narayan
  • Hi Narayan,

    The graphs are made in Flash ...
    So i guess , there has to be something else to invoke a click.
    However , There is a blog :http://ashwinilalit.blogspot.com/2010/10/how-to-automate-flash-chart-using-sahi.html
    but the algorithm is lil complicated to understand...Can this be really done???

    Thank you for the Help!! :)

    Regards,
    Akshada
Sign In or Register to comment.