Css3selector and css3xpath not working

community-edition
#1

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

#2

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

#3

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.

#4

Hi,

You can simply paste the copied css selector.

Regards,
Amit

#5

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

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

#6

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

#7

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

#8

Hi,

No encoding is required. You can simply put as is

Regards,
Amit

#9

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.”

#10

Are you trying to select a value from dropdown ?

#11

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.

#12

HI,

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

Regards,
Amit

#13

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

#14

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

#15

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

#16

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

#17

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.

#18

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