setirich Posted September 4, 2017 Posted September 4, 2017 (edited) Hi All! Having a problem with clicking on a specific web page location. Of course, it's Javascript, and that just make it 10x harder. I'm doing all the searching within this construct $Htmcpy = _IDBodyReadHTML($oIE) I then write out the page to a file, and then attempt to find and click on the next page indicator. I can locate the proper spot within the string easy enough, but having trouble with what I do to click on the page marker. Here is the HTML string that contains the item to click on: <td><span>1</span></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$2')">2</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$3')">3</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$4')">4</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$5')">5</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$6')">6</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$7')">7</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$8')">8</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$9')">9</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$10')">10</a></td><td><a style="color: white;" href="javascript:__doPostBack('gvResults','Page$11')">...</a></td> The actual text on the page looks like this: 12345678910... and the total number of pages may be into the thousands. Yes, there are only 10 records per page & to get beyond 10 I actually have to click on the ... to get the next group of numbers up. So I can end up with a text string that looks something like this 1234123512361237123812391240... A simple regex finds and extracts the page number I want Local $xp = $X + 1 ; I want the next page which is current page plus 1 Local $rexp = ">(" & $xp & ")</a>" ; this locates the page # and extracts is to Local $page = $ox[0] ; the actual page as displayed I've tried a lot of things like trying to focus on that spot ID'd. within that text string OR the html string, and then click on it. Any ideas on where to start? Thanks, Rich Edited September 4, 2017 by setirich spelled my name wrong!!! Good intentions will always be pleaded for every assumption of authority. It is hardly too strong to say that the Constitution was made to guard the people against the dangers of good intentions. There are men in all ages who mean to govern well, but they mean to govern. They promise to be good masters, but they mean to be masters.-Daniel Webster
junkew Posted September 5, 2017 Posted September 5, 2017 Not sure but try FAQ31 see link below Which udf are you using? or are you parsing plain HTML? FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Danp2 Posted September 5, 2017 Posted September 5, 2017 Can you share the site URL? Have you checked to see if the page # updates in the URL as you switch pages? Latest Webdriver UDF Release Webdriver Wiki FAQs
setirich Posted September 5, 2017 Author Posted September 5, 2017 Thanks for your replies. I'm using the latest (?) AU3 version 3.3.14.2, and I've used the built in IE.au3 since it was first released as part of the general release. I think I used Dales original UDF since he first posted it years ago. There is not a simple URL change on page change. That's always the first choice for simple scraping. Here is the URL for the search page: http://www.occeweb.com/MOEAsearch/index.aspx For example, put in just the letter p in the last name box, and select the Begins with option button. you'll get 2793 records, and that will be 280 pages. My experimentation so far actually gets the data on the page, but will not advance to page 2, 3, etc. Therefore, I get many copies of the first page, which is not what I want. Good intentions will always be pleaded for every assumption of authority. It is hardly too strong to say that the Constitution was made to guard the people against the dangers of good intentions. There are men in all ages who mean to govern well, but they mean to govern. They promise to be good masters, but they mean to be masters.-Daniel Webster
Danp2 Posted September 5, 2017 Posted September 5, 2017 Perhaps you could use Eval() to directly execute the Javascript command. Take a look at this thread for a detailed discussion. Latest Webdriver UDF Release Webdriver Wiki FAQs
setirich Posted September 5, 2017 Author Posted September 5, 2017 I'm not sure why eval would help me. I already know the specifics of the java as it's like this (for page 2): <a style="color: white;" href="javascript:__doPostBack('gvResults','Page$2')">2</a> Each page will be similar with a change toe the ~Page$2">2</a> to Page$3">3</a> I think this is one of those things that requires a 'real' click on the >2< and it's just a question of how to actually do that. But then, I'm probably totally wrong....8-\ Good intentions will always be pleaded for every assumption of authority. It is hardly too strong to say that the Constitution was made to guard the people against the dangers of good intentions. There are men in all ages who mean to govern well, but they mean to govern. They promise to be good masters, but they mean to be masters.-Daniel Webster
junkew Posted September 5, 2017 Posted September 5, 2017 _IEAction($object, "click") FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
Danp2 Posted September 5, 2017 Posted September 5, 2017 56 minutes ago, setirich said: I'm not sure why eval would help me. I already know the specifics of the java as it's like this (for page 2): <a style="color: white;" href="javascript:__doPostBack('gvResults','Page$2')">2</a> Each page will be similar with a change toe the ~Page$2">2</a> to Page$3">3</a> Exactly... so instead of trying to locate the appropriate element and then click on it, I was suggesting that you use Eval() to execute the Javascipt command to take you to the desired page. Latest Webdriver UDF Release Webdriver Wiki FAQs
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now