Cannot click on a link that have href='javascript:doPage'

The Report on the application, has Pagination.
The goal is to scrap data from each page.

Pagination links have following stricture
//href=“javascript:doPage(1);”
//href=“javascript:doPage(2);”
//href=“javascript:doPage(3);”
etc.

The solution should be simple.
{
“Command”: “click”,
“Target”: “//a[@href=‘javascript:doPage(1);’]”,
“Value”: “”,
“Description”: “”
}
However, the click in visible on a screen, but next page is not displayed.
See recording

I have trayed deferent approaches, non is working

{
  "Command": "store",
  "Target": "2",
  "Value": "link_position",
  "Description": ""
},
{
  "Command": "XClick",
  "Target": "//a[@href=\"javascript:doPage(${link_position});\"]",
  "Value": "",
  "Description": ""
},
{
  "Command": "click",
  "Target": "//a[@href=\"javascript:doPage(${link_position});\"]",
  "Value": "",
  "Description": ""
},
{
  "Command": "click",
  "Target": "//a[contains(@href, 'javascript:doPage')][${link_position}]",
  "Value": "",
  "Description": ""
},
{
  "Command": "click",
  "Target": "//tr[@class=\"pagging_header\"]//a[${link_position}]",
  "Value": "",
  "Description": ""
},
{
  "Command": "clickAndWait",
  "Target": "linkText=${link_position}",
  "Value": "",
  "Description": ""
}

Try XClick instead of Click, that should solve it.

25 “xCommands” limit per day for non payed UIV version.
The frame work servicing 1500 clients. The boss do not willing to pay :pensive:

I think UIV is very well worth the money, but if you can not afford it right now, see this post for a workaround for unlimited xclicks in the free version:

its 25 per macro run

1 Like

Well, it do not help me much
i am scraping data from reports for same User.
Reports may have hundreds of pages

try javascript click

can u please give an example

read javascript DOM click () method
example

document.getElementById('elementID').click();
1 Like

well, i have tried it. It is not working for us.
The reports are very old and purely designed. The element do not have id or name
only “href”

<tr class="pagging_header">
  <td colspan="11" align="right">
	  <a href="javascript:doPage(1);">First</a> 
	  <a href="javascript:doPage(2);">2</a> 
	  <a href="javascript:doPage(3);">3</a> 
	  <a href="javascript:doPage(4);">4</a> 
	  <a href="javascript:doPage(5);">5</a> 
	  <a href="javascript:doPage(6);">6</a>
  </td>
</tr>

var x= document.getElementsByTagName(“a”);
x[0].click();

this is just an example

you have to first get tag TR and then loop through tag A

you can get to TR using getElementsByClassName

@admin This issue is not present in UIV v2.2.8.
Please advise. i have trayed all work arounds that have been subjected.
Non working on our portal.

But with XClicks it works, or?

click/xClick with xPath / CSS is not working
I am not able to use getElementsByName or getElementsByClassName, the tag do not have ‘id’ or ‘name’ attributes.
I am was not able to get the solution proposed by @uiuser work. :disappointed:

look like i will have to try to revert to a UIV v6.2.8

try with querySelector()
or querySelectorAll()

thanks for reply, but i am not sure how to do it.
any tutorial that i can look into?

var x = document.getElementsByClassName("pagging_header")[0].getElementsByTagName("a");
alert (x.length);

run this in chrome console and tell the output

it is not a problem to run it in console as a JS.
I know how.
I need to be able to use this JS in UIVision Click

1 Like
<html>
<body>
<a href="https://www.youtube.com/" target="_blank">youtube</a> 
<br>
<a href="https://www.google.com/" target="_blank">google</a>
</html>
</body>



  {
      "Command": "executeScript",
      "Target": "document.getElementsByTagName(\"a\")[0].click();",
      "Value": "",
      "Description": ""
    }
    }
2 Likes

oh, thanks, will try next week,