question

rshankar avatar image
rshankar asked ericnute edited

Using xpaths

I have an HTML page that has different fields over different tables with the same variable name on the form. I'm attaching the HTML source code for reference. Is there a way I can access these fields independently using xpaths queries? I do not want to hardcode the table/td/tr values as the UI may change in the future.

Regards

Ramachandran Shankar

iTestresponse mapxpath
UI_att.txt (29.4 KiB)
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
sreenath avatar image
sreenath answered sreenath posted

Yes, we can use the xpath to retrieve the table contents with the help of the HTML response.

 

Please find the attached test case for your reference. We can extract the xpath from the structure view.

 

Hope it helps.

 


sample.fftc (4.0 KiB)
xpath.jpg (122.1 KiB)
2 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rshankar avatar image rshankar commented ·

Hi

The HTML page that we have here shows the IP allocation properties of the LAN devices connected to the gateway. Hence the page details are subject to change. Is there a way I can access a particaular set of fields related to a LAN device based on the IP address. For example in the given page, if I pass the arguements IP address = 192.168.1.204 and Firewall = Disable to a procedure, it should be able to select the firewall option FWENABLE as DISABLED for the device 192.168.1.204.

 

Regards

Ramachandran

0 Likes 0 ·
mallikarjunarao avatar image mallikarjunarao rshankar commented ·

shankar,

 

I used two queries two get IP address and firewall option

 

[query var mapped/Xml/WebDocument/Document/HTML/BODY/DIV/DIV[3]/DIV/DIV[2]/DIV/FORM/TABLE[1]/TBODY/TR[TD='192.1681.204']

[query var mapped/Xml/WebDocument/Document/HTML/BODY/DIV/DIV[3]/DIV/DIV[2]/DIV/FORM/TABLE[1]/TBODY/TR[3]/TD[1]/SELECT[OPTION='Disabled']

 

If you want create a procedure for this replace IP Address and Firewall option use field substitution variables

 

[query var mapped/Xml/WebDocument/Document/HTML/BODY/DIV/DIV\[3\]/DIV/DIV\[2\]/DIV/FORM/TABLE\[1\]/TBODY/TR\[TD='$IP'\]

[query var mapped/Xml/WebDocument/Document/HTML/BODY/DIV/DIV\[3\]/DIV/DIV\[2\]/DIV/FORM/TABLE\[1\]/TBODY/TR\[3\]/TD\[1\]/SELECT\[OPTION='$firewallOption'\]

 

Let me know if you get any error

 

Thanks

Mali

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.