Special clicks

Sometimes the no-code 'Click' step provided by Axiom doesn't capture what you want to do.

Simple single and multiple clicks can be achieved with no-code, but using some javascript you can perform more complicated clicks.

# Click All Elements Containing Text

This may be useful if you want to click items in a list, or a particular item in a list. For example, an address.

Copy-paste the following code into axiom's 'Write JavaScript' step.

You can use data output by other steps here, as well, replacing the hardcoded value 'TEXT'.

document.querySelectorAll("INPUT SELECTOR HERE").forEach(function(el) {
    // Input the text you want to search. You can use data output by other steps here, as well.
	if (el.outerHTML.includes('TEXT')) {
		el.click();
	}
});

Copy and paste the following code into axiom's 'Write JavaScript' step.

You can use data output by other steps here, as well, replacing the hardcoded value 'TEXT'.

document.querySelectorAll("CUSTOM SELECTOR HERE").forEach(function(el) {
	if (el.outerHTML.includes('TEXT')) {
		el.getElementsByTagName('a')[0].click();
    }
});

This will get the first a tag that's a child of the elements you're selecting (usually a row or list).

If you want to select the 2nd a tag within that list, increment [0] to [1] as follows:

	el.getElementsByTagName('a')[1].click();

You can change the type of tag here from a to button or any other type:

	el.getElementsByTagName('button')[0].click();

If you want to select by Class name:

	el.getElementsByClassName('red')[0].click();

# Example

Try the following example on axiom.ai/demos/nytimes.html . It will Click the Dubai Article.

document.querySelectorAll("ol li").forEach(function(el) {
	if (el.outerHTML.includes('Dubai')) {
		el.getElementsByTagName('a')[0].click();
	}
});