Overview
There are several different reasons why a click or clickAndWait action may not work properly. One common cause of this is when the webpage contains multiple objects with the same ID. While IDs are meant to be unique per webpage, browsers are forgiving and do not require it. By default, the agent will click on the first matching ID it finds.
Workaround
A workaround for this is to mark the index of the ID using 1-based indexes, so to click the 3rd instance of the ID on the page, the verb would look like this: clickAndWait(//div[@id='login'][3]).
Another workaround in this case is to use a regular expression as the locator for the click instead of the ID. For example: clickAndWait(link=regexp:login).
This only works if the body text "login" (as shown in regexp) is present inside the anchor tag e.g. "<a href="#">login</a>".
In other cases, a Javascript event may not be triggered. For instance, some pages are coded so that a button utilizes the click event for further activity to occur. For these instances, a simple click verb may not be sufficient, and you may need to use the fireEvent verb.
Examples
The usage of this verb is as follows:
fireEvent(locator, event)
Example: fireEvent(//*[@id='option-0-a'],'click')
Note that different browsers behave in various ways regarding events and interactivity, depending on how pages are coded. The following transaction script supports Chrome:
// Step - 1
open(http://www.grainger.com/custom/locks/)
fireEvent(//*[@id='option-0-a'],'click')
select(//*[@id='field5'], 'label=A2000')
fireEvent(//option[@value='31289'], 'click')
click(//*[@id="field19"])
select(//*[@id='field22'], 'label=Keyed Different')
click(//option[@value='31478'])
click((//input[@id='field25'])[2])
pause(1000)
click((//input[@id='field30'])[2])
type(//*[@id='submit-quantity'], '2')
click(//*[@id='confirm'])
// Step - 2
clickAndWait(//*[@id='submitadd'])