Forum Discussion

apurvak's avatar
apurvak
Occasional Contributor
6 years ago

Not able to insert value in textbox.

Hi,

 

I am trying to insert value/string in a textbox using JavaScript but it is giving me error as "The object does not exists." I have used XPath for inserting the value. I have tried using Object Spy but I am unable to insert value in textbox. 

 

While using XPath for textbox one thing is observed: the same XPath is used for another textbox and because of this I getting error.

 

Could you please let me know if there is any solution for this?

 

5 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Please provide:


    - Object Browser data of your element
    - source code of your page (at least the piece, that contains your textbox)
    - the XPath you are using

  • apurvak's avatar
    apurvak
    Occasional Contributor

    Code:

    var verlbl = openbr.page.FindChildByXPath("//div[3]/table/tbody[1]/tr[1]/td[2]/div/input", true);

    var vlbl = Driver.Value(9).toString();
    var finalvlbl = (vlbl+Math.floor((Math.random()*100)+1));

    verlbl.Keys(finalvlbl);

    var str1 = "NA";
    var str3 = Driver.Value(10);
    if(str1.valueOf() == str3.valueOf())
    {
    Log.Message("Release status is not provided to add");

    }
    else
    {
    //var rlsdropdown = openbr.page.FindChildByXPath("//div[3]/div[2]/div[1]/div[3]/div/div/div/div[3]/div/div[3]/table/tbody[1]/tr[1]/td[2]/div/span/input",true);
    var prop2 = Array("ObjectType","Height");
    var val2 = Array("Textbox","24");
    var rlsdropdown = openbr.page.FindChild(prop2,val2,30);
    //Sys.HighlightObject(rlsdropdown);
    rlsdropdown.Click();

    var prop1 = Array("ObjectType","contentText");
    var val1 = Array("TextNode",str3);
    var releasestatus = openbr.page.FindChild(prop1,val1,20);
    releasestatus.Click();

    }
    // insert value in text box
    var remarks = openbr.page.FindChildByXPath("//div[3]/div[2]/div[1]/div[3]/div/div/div/div[3]/div/div[3]/table/tbody[1]/tr[2]/td[2]/div/textarea",true);
    remarks.Keys("^a");
    remarks.Keys("[Del]");
    remarks.Keys(Driver.Value(11));


    /*var prop3 = Array("ObjectType","sourceIndex");
    var val3 = Array("Textarea","408");
    var remarks = openbr.page.FindChild(prop3,val3,20);
    remarks.Keys(Driver.Value(11));*/

    var swappln = openbr.page.FindChildByXPath("//div[3]/div[2]/div[1]/div[3]/div/div/div/div[3]/div/div[3]/table/tbody[1]/tr[4]/td[2]/div/textarea",true);
    swappln.Keys("^a");
    swappln.Keys("[Del]");
    swappln.Keys(Driver.Value(12));

    /* var prop4 = Array("ObjectType","sourceIndex");
    var val4 = Array("Textarea","416");
    var swappln = openbr.page.FindChild(prop4,val4,20);
    swappln.Keys(Driver.Value(12));*/

    var props = Array("tagName", "contentText");
    var values = Array("button", "Ok");
    var link2 = openbr.page.FindChild(props, values, 10);
    if(link2.Exists)
    link2.Click();
    openbr.page.Wait(); Delay(2000);

     

    Please find attached screenshot for object browser properties. 

  • apurvak's avatar
    apurvak
    Occasional Contributor

    I have tried name mapping approach but still it is not working.