How to capture multiple objects from multiple iframes on a webpage

Your XPath expression:

This will not select the node you want.

Rather you should write:

(//*[local-name()='svg']//*[local-name()='path' and @elementargument='Subs'])[1]

You may wonder what //*[local-name='svg']//*[local-name()='path'' ....' is. Before talking about it, let me ask you some questions:

  1. Are you aware of the concept of XML Namespace?
  2. Are you aware that the node you want to click belongs to the Namespace of Scalable Vector Graphics?
  3. Are you aware that the node you want to click does not belong to the Namespace of XHTML?
  4. Are you aware that you have a node <html xmlns="http://www.w3.org/1999/xhtml"> as the ancestor of your target node?
  5. The screenshot you provided does not show it, but most probably you would have a node <svg xmlns="http://www.w3.org/2000/svg"> as the ancestor of your target node. Am I right?

If you do not understand my questions, you need to study “XML Namespace” specification first. Otherwise you would be lost forever.

Also you would want to study XPath local-name() and name() functions:


Here is my previous post about selecting a SVG node contained in a HTML document. Please have a look.

1 Like