How to force Fake.app to connect an HTML element by XPath (instead of "id" attribute)
I want to "connect" a Fake Action to an HTML Element on the page via XPath, but when I try to connect the Element, the Element is specified by HTML id
attribute instead.
How do I force Fake to specify an HTML Element by XPath when "connecting"?
Developer of Fake here.
First, make sure you understand the concept of "Connecting" in Fake.
Fake allows you to specify an HTML Element via one of several methods:
- HTML
id
attribute - HTML
name
attribute - CSS Selector
- XPath Expression
- arbitrary JavaScript Expression
Connecting is an automatic way to specify an Element. Fake can only connect an Element using one of two methods:
- HTML
id
attribute - XPath Expression
If you want to specify via one of the other methods you must do so "by hand".
When you connect an Action to an HTML Element, Fake will first try to specify the connected Element using the HTML id
attribute. If that is not possible (becuase the Element has no id
attribute), Fake will try to specify the connected Element using XPath.
Via id
is the default because it is efficient and easily understandable.
Via XPath is the fallback because it is always possible, but less efficent and less easliy understandable.
However, there are times when you might prefer to connect an Action to an Element, but specify the Element via XPath instead of id
. This is possible via the steps below:
- First add a connectable Action (like
Set Value of HTML Element
) to your Workflow. -
Before connecting, change the specifier type to
for XPath
. - Then connect as normal. Hold the control key (
⌃
) while dragging from the Action to an Element on the page.
The Element will now be specified via XPath, instead of id
.