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.

Query in Java driver

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


I was using sahi script for Automation, but now i switched to Java driver for Automation using SAHI.
In script, I was using _getCellText(_div("value")) to get string of that div.
How we can use this in Java driver to get that string ?

Comments

  • TheeranTheeran Members
    Hi Vikkyjain,

    Try with

    browser.div("divId").getText();

    This might help you.

    Thanks,
    Theeran.
  • Hi Theeran,

    I tried this, but its not working. It throws an exception.

    I tried following scenarios.

    a. browser.div("value").fetch("innerHTML");
    b. browser.div("value").getText();
    c. browser.div("value").getValue();

    It throws following exceptions respectively

    a. error:_sahi.setServerVarPlain('___lastValue___Mon Jun 25 14:51:36 IST 2012', _div("QLE8362").innerHTML)
    TypeError: _sahi._div("QLE8362") is undefined
    http://172.35.23.56:8080/_s_/spr/concat.js:3016
    http://172.35.23.56:8080/_s_/spr/concat.js:3016
    http://172.35.23.56:8080/_s_/spr/concat.js:2822

    at net.sf.sahi.client.Browser.executeStep(Browser.java:223)
    at net.sf.sahi.client.Browser.execute(Browser.java:190)
    at net.sf.sahi.client.Browser.fetch(Browser.java:478)
    at net.sf.sahi.client.ElementStub.fetch(ElementStub.java:515)
    at automation.testing.Commonfunctions.clickOnAdapter(Commonfunctions.java:31)
    at automation.testing.Sample.main(Sample.java:24)


    b. error:_sahi.setServerVarPlain('___lastValue___Mon Jun 25 14:52:00 IST 2012', _getText(_div("QLE8362")))
    Error: The parameter passed to _getText was not found on the browser
    at net.sf.sahi.client.Browser.executeStep(Browser.java:223)
    at net.sf.sahi.client.Browser.execute(Browser.java:190)
    at net.sf.sahi.client.Browser.fetch(Browser.java:478)
    at net.sf.sahi.client.Browser.getText(Browser.java:501)
    at net.sf.sahi.client.ElementStub.getText(ElementStub.java:289)
    at automation.testing.Commonfunctions.clickOnAdapter(Commonfunctions.java:37)
    at automation.testing.Sample.main(Sample.java:24)


    c. error:_sahi.setServerVarPlain('___lastValue___Mon Jun 25 14:52:27 IST 2012', _div("QLE8362").value)
    TypeError: _sahi._div("QLE8362") is undefined
    http://172.35.23.56:8080/_s_/spr/concat.js:3016
    http://172.35.23.56:8080/_s_/spr/concat.js:3016
    http://172.35.23.56:8080/_s_/spr/concat.js:2822

    at net.sf.sahi.client.Browser.executeStep(Browser.java:223)
    at net.sf.sahi.client.Browser.execute(Browser.java:190)
    at net.sf.sahi.client.Browser.fetch(Browser.java:478)
    at net.sf.sahi.client.Browser.getValue(Browser.java:512)
    at net.sf.sahi.client.ElementStub.getValue(ElementStub.java:370)
    at automation.testing.Commonfunctions.clickOnAdapter(Commonfunctions.java:44)
    at automation.testing.Sample.main(Sample.java:24)
  • Hi Theeran,

    On Application my div is like this

    <div class="style-class">value</div>
Sign In or Register to comment.