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.

Usage of parentNode in Java

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

I have two objects (One Div, and One Input) on the screen with following xpaths. (Only last part of the xpath is pasted here).
Object 1: table/tbody/tr[2]/td[2]/table/tbody/tr/td/table/tbody/tr/td/div
Object 2: table/tbody/tr[2]/td[3]/input

On screen the div and input are shown in the same row. To make a logical reference, I need to setValue of the input based on the corresponding input.

The div has a text value that is being used as identifier. (Kind of a row label)

I am trying to use the following code but I don't get any result. It's always "Error: The first parameter passed to _setValue was not found on the browser".

If the text in div tag is "label",
browser.textbox(0).in(browser.cell(2).in(browser.div("label").parentNode("TR",3))).setValue("testValue");

Comments

  • narayannarayan Administrators
    Have you tried

    browser.textbox(0).near(browser.div("Your label")).setValue("testValue")

    ?
  • @Narayan - I have already tried that and it doesn't work. My assumption was that near works at the same level in the DOM structure. Do you mean to say near works for every element at and under the structure?
  • narayannarayan Administrators
    _near looks for matching elements in the same DOM level and up to 7 levels up.
    I think your element is just above that node. Try:

    browser.textbox(0).near(browser.div("Your label").parentNode("TABLE")).setValue("testValue")
  • ganeshprganeshpr Members
    edited February 2011
    narayan wrote:
    _near looks for matching elements in the same DOM level and up to 7 levels up

    In my case the div element is 8 levels down. Are you sure _near looks 7 levels up? or is it 7 levels down? In any case, what is the workaround you would suggest for more than 7 levels?
Sign In or Register to comment.