Css3selector and css3xpath not working

On a webapp that I am trying to automate css3selector and css3xpath are both not working! How do I need to code the following xpath (generated in Chrome) to work with IE and Automation Studio.
//*[@id=“LDAPResults”]/form/table/tbody/tr[3]/td[2]/table/tbody/tr[1]/td[2]/span

You can try using Manual selector in the “Find By” instead of the CSS selectors. It helps creating a selector based on control attributes.

I know I can use the manul find by option but my question is how do I code the xpath that I gave in my original post.

Hi,

You can simply paste the copied css selector.

Regards,
Amit

The Value that appears if I select the css3selector option is:

:nth-child(3) > :nth-child(2) > :nth-child(1)

Hi,

The same is generated by default. If during run time system is not able to find the control using same then try using css selector which works for you by replacing the default value.

Regards,
Amit

In order to replace the default value I need to know what the syntax rules are, or more explicilty how to encode the xpath //*[@id=“LDAPResults”]/form/table/tbody/tr[3]/td[2]/table/tbody/tr[1]/td[2]/span as a css3selector or css3xpath

Hi,

No encoding is required. You can simply put as is

Regards,
Amit

I have tried to use the xpath string as is with find by set to css3selector, css3xpath and manual all three fail with error message “Value does not fall within the expected range.”

Are you trying to select a value from dropdown ?

Hi Amit,

No it is a set of “plain” text fields that I am trying to get the values for. Attached is an image of the inspect element of the field that I gave the example xpath value for.

I know that the details are available on the web page because; it is possible to get the full block of personal details that I am trying to retrieve from the web page using “td > table”,
but then I can’t handle the individual fields that are part of the personal details.

HI,

Is this web application publicly available so that i can have a look on the same

Regards,
Amit

No it’s an intranet application (of the client that I work for).

OK
Are you able to get that text field web element using Java Script. AS a workaround, then you can use a java script executor block to fetch the value
Regards,
Amit

I had tried to use an "Execute JavaScript block with the following Java script that I got from a colleague; but it too fails to return a value.

var path= “//*[@id=“LDAPResults”]/form/table/tbody/tr[3]/td[2]/table/tbody/tr[1]/td[2]/span”;
return (document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue).innerHTML

Hi,

Press F12 and open browser console

document.getElementsByClassName(‘WhoDataClass’).length

see how many HTML element you get. Check the index of your desired web element
document.getElementsByClassName(‘WhoDataClass’)[index of desired element].innerHTML should give the text

Hi Amit,

I tried your document.getElementsByClassName code from the browser console but got an Invalid Character error.

After correcting this to use double quotes I got a different error (see image).

This got me thinking about the path string that I had pasted into in the java code that I got from my colleague so I tried that again after using a backslash to escape the double quotes
in the string. Whilst testing this I notice in the AssistEdge log files the following error:

…….
errormessage~SyntaxError: ‘return’ statement outside of function
……

Working with the browser console I eventually managed to work out that the document.evaluate method is also not available.

With lots of trial and error I eventually managed to find a document statement that does return the desired value:

document.getElementsByName(“LDAPResults”).LDAPResults.childNodes[0].childNodes[4].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].innerText

But this is still not returning that value to the Parameter used in the Execute JavaScript block.

Hi,

What is the browser version that you are using

Also, when you are expecting a value to return un JS executor block add return at start of JS code.

Regards,
Amit

The version of browser is Internet xplorer 11.0.9600.19356

With regards to the value not returning and your comment to add return at the start of JS code can you please clarify this in relation to the example JS code that I had provided in previous posts and the Syntax Error memtioned in my previous post…

return document.getElementsByName(“LDAPResults”).LDAPResults.childNodes[0].childNodes[4].childNodes[0].childNodes[2].childNodes[1].childNodes[0].childNodes[0].childNodes[0].childNodes[1].innerText