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.

Sahi Script on IE and FireFox

ddivakarsddivakars Members
edited November -1 in Sahi - Open Source
Hi,

The Sahi script recorded on IE (internet explorer) does not seem to run fine on FireFox.

On the web page(gwt), Sahi records the first text box field as textbox(0), second one as textbox(1) etc...where as on FireFox, it reads the same fields as textbox(4), textbox(5) etc...

I have tried using browser.textbox(0).near(...) and browser.textbox(0).in(...) but they did not work.

Could you please provide a solution or a workaround?

I would like to have one script to run both on IE and FireFox.


Thanks in advance
-Diwakar

Comments

  • globalwormingglobalworming Moderators
    edited February 2011
    a workaround could be, that you use a branch in your script.. like

    if(_isFF()) { _textbox(4) }
    else if (_isIE()) { _textbox(0) }

    Edit: APIs are others:
    Apart from navigator.appName and navigator.userAgent, there are Sahi APIs
    _isIE
    _isFF
    _isFF3
    _isChrome
    _isSafari
    which can be used to check for browsers.
  • This workaround works fine with the Textbox fields but not the Checkbox fields.

    I am currently using (on IE) -- browser.checkbox(0).near(browser.div("ABCD").check()
    to check the checkbox near the text ABCD.

    this script does not work on FireFox. same is the issue with radiobutton fields.
  • narayannarayan Administrators
    Hi Divakar and Wormi,

    Try not to use the "if" conditions. We need to see why the "near" APIs are not working. Is the checkbox identified as "browser.checkbox" and the div identified as "browser.div" on both browsers?
    In the code you have posted, 'browser.checkbox(0).near(browser.div("ABCD").check() ' is missing a bracket. (May be a typo, so,) could you please post real code here?

    Regards,
    Narayan
  • Hi Narayan,

    Yes it was just a typo.

    I have scripts running fine on IE. The 'near' API works fine for checkbox on IE.

    The same script does not work on FireFox because of the following reason.
    The attributes of textbox fields are different in FF from IE.
    like the example I said in my previous post, the first textbox on each page is read as textbox(0) on IE and some inconsistent value on FireFox, like textbox(1) or textbox(4)

    When used the workaround suggested by Wormi (branching for all textbox fields) I am able to run some script both on IE and FireFox.
    But, this workaround does not seem to work on checkboxes or radiobuttons.


    my page contains:

    Find [ ] (texbox field) [Go] [Reset] [Refresh]

    [Actions] (menu bar with some options)
    (checkboxes)
    [] ABCD
    [] XYZ
    [] PQRS



    my code...:

    browser.div("Profiles").click();
    if ("true".equals(browser.fetch("_sahi._isIE()")))
    browser.textbox(0).setValue("ABCD");
    else
    browser.textbox(5).setValue("ABCD");

    browser.div("Go[1]").click();

    if ("true".equals(browser.fetch("_sahi._isIE()")))
    browser.checkbox(0).near(browser.cell("ABCD")).check();
    else
    browser.checkbox(1).near(browser.cell("ABCD")).check();

    browser.waitFor(2000);
    browser.div("Actions[1]").click();



    This runs fine on IE.
    On FireFox, it stops at checking the checkbox. (I have tried providing attribute values from 0 - 15 for checkbox but no luck)



    I have also tried the following code: But this did not even set the textbox value on IE or FF.

    browser.div("Profiles").click();
    browser.textbox(0).near(browser.div("Find").setValue("ABCD");
    browser.div("Go[1]").click();
    browser.checkbox(0).near(browser.cell("ABCD")).check();

    thanks
    -Diwakar
Sign In or Register to comment.