Bot is not able to execute click action on text in web element

I am working on assignment 10 in “Building Bot Tasks with RPA Express” course. I am able to search for the product on Amazon but I am not able to find a way to click on the right product in the search result. I tried following approaches:

  1. Find a xpath (//*[@id=“result_x”]/div/div/div/div[2]/div[1]/div[1]/a/h2) for a product and use a loop to go through all the elements (in “result_x” - x is replaced by numbers the loop) in page and find the xpath of the product that matches the product name. Click the product (using xpath). It worked pretty well for some of the products but it broke when xpath (xpath template used in the loop) changed for some products.
  2. Second approach was simple, using a click action on the web element with text. This didn’t work at all. I kept on getting error “Error executing MouseClickAction”.

Please let me know if I am doing anything wrong or suggest an approach that will work.


Hi, Amar! You can try other XPath expressions, for example - “//*[contains(text(),‘products’)]”.


Thanks, Abrakovich. Your suggestion helped in resolving the problem. I used “h2” instead of “text()” since I wanted bot to click on the text in “h2” tag.

1 Like