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.

Setting Value in _div Element

spchinspchin Members
edited July 2011 in Sahi - Open Source
When trying to set the value of a _div element I am running in to issues. It is an editable _div element and _setValue is not working. The code which I have now is:

_popup("BusinuessOfficeEntry")._setValue(_div("mocsEditableDiv"), "1");

I am trying to set the value of the _div element to 1. I have searched on the forums and found that _setValue doesn't work on _div elements? If this is true, is there any other API to set the value of the _div?

EDIT: Here is some more info about the element:

<div class="mocsEditableDiv" contentEditable="true" onfocus="editableDivOnFocus(this)" _ordersInd="N" _funcActionId="100538" _funcActnAttribId="103057" _privValue="" _caseBalance="" _parentDivId="div1311802167361" _curText="" initHeight="15" initWidth="178" hasAttached="true"/>

Comments

  • spchinspchin Members
    So I made some progress on this issue. I used the following line of code to set the editable div to 1:

    _popup("BusinuessOfficeEntry")._setValue(_div("mocsEditableDiv").innerHTML= 1);

    On the screen it shows up that the div element has a 1 in it, but the program doesn't recognize that there is a value in the div element. Is there another property where I need to enter the value in to?
  • SumitraSumitra Members
    Hi spchin,

    Check if the controller identifies the div as textarea after you click on div. If so then check the following example to set the value in the textarea.
    _navigateTo("http://docs.dojocampus.org/dijit/InlineEditBox");
    _click(_link(30));
    _click(_div(160));
    _setValue(_textarea("dijit_form_Textarea_0"),"Hello");
    _click(_button(0));
    

    If the controller shows as div after you click div then kindly check this example:
    _navigateTo("http://www.sedh.gr/tutorials/web_dev/JSDHTML/JSDHTML12/jsdhtml12-02.htm");
    _click(_submit("View Code"));
    _call(_div("EditDIV").innerHTML="hello");
    

    Let me know if this solves your issue.

    Regards
    Sumitra
  • spchinspchin Members
    edited August 2011
    Hi Sumitra,

    The controller still shows the div element as a div after clicking on it. I tried to check out the website for the second example you gave, but the website says the bandwidth is exceeded everytime I check. Do you have another example you could give?

    I tried using the _call line of code and I still get the same error; the _div element shows that it has a value in it, but the program doesn't recognize that there is anything there.

    UPDATE:

    So I changed my original code to this:

    _popup("BusinuessOfficeEntry")._call(_div("mocsEditableDiv").nodeValue= "1");
    _popup("BusinuessOfficeEntry")._call(_div("mocsEditableDiv").innerHTML= "1");

    Now the program recognizes there is something in the div, but only if I click on it with my mouse. When I try to use the _click API it won't work.
  • I got a chance to look at the example but it appears to be exactly what I am doing. Anyone else have suggestions?
  • Hi spchin,

    Can you please post the script and the URL?

    Regards
    Sumitra
  • I have the script posted above, but here it is again:

    _popup("BusinuessOfficeEntry")._setValue(_textbox(5), "SEFI");
    _popup("BusinuessOfficeEntry")._keyPress(_textbox(5), 9);
    _popup("BusinuessOfficeEntry")._call(_div("mocsEditableDiv").innerHTML= "1");
    _popup("BusinuessOfficeEntry")._call(_div("mocsEditableDiv[1]").innerHTML= "20");

    The URL won't work for you since this is still in development. I'll describe what it is the best I can though. The pop- up allows you to enter different codes and record them. The code entered here is "SEFI", which is followed by the tab key. Once that key is pressed the _div elements come up. You can see that I am entering values in to 2 of the editable _div elements.
  • Hi spchin,

    Can you try using this:

    _eval("_div('mocsEditableDiv').innerHTML = '20'");

    Let me know if this solves your issue.

    Regards
    Sumitra
  • spchinspchin Members
    edited August 2011
    I tried the code you provided but got the following error message:

    _eval("_div('mocsEditableDiv').innerHTML = '1'");
    TypeError: '_sahi._div(...)' is null or not an object
    No trace available

    I changed the code to this but I had the same problem I had before. I have to click in the textbox of the second _div element and then the application will recognize that there is a value in there.

    _popup("BusinuessOfficeEntry")._eval(_div("mocsEditableDiv").innerHTML= "1");
    _popup("BusinuessOfficeEntry")._eval(_div("mocsEditableDiv[1]").innerHTML= "20");

    I thought of using _removefocus or _blur but I can't seem to get the syntax right. I was thinking that I could remove focus from the first element and put it on the second?
  • Hi spchin,

    _eval() API will evalute in the main window and not in pop up window.

    So the code should be:

    _popup("BusinuessOfficeEntry")._eval("_div('mocsEditableDiv').innerHTML = '12'");
    _popup("BusinuessOfficeEntry")._eval("_div('mocsEditableDiv[1]').innerHTML= '20'");

    Regards
    Sumitra
  • Hey Sumitra,

    I tried the code you provided but I am still getting the same error. The application doesn't recognize that there is a value in the mocsEditableDiv[1] until I physically click in the cell. I don't have to type anything, but the cursor needs to appear in the cell. I tried using the _click API, but it doesn't seem to make the cursor appear in the cell, even if I put a _wait(5000) command after it.

    The controller shows SUCCESS after playback, but the information is not getting stored correctly and the application shows an error.
  • Does anyone else have any suggestions?

    Sumitra- I emailed you back, did you receive it?
  • Have you been able to fix this?
    I'm having the same problem.
    I have multiple elements inside my div tag, but for some strange reason, I can retreive all the other except my textarea. Nothing comes up when I hover over it. I tried to access it by its name and set textarea with its name - but it throws an error message.
    Can someone help me?
    Using latest version of Sahi.
  • Hi Widunder,

    Can you please point us to your application?

    If not then could you please post the html code for the div tag and the textarea field.

    Regards
    Sumitra
Sign In or Register to comment.