Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VFP Web automation and form filling
#4
Hi,

There are multiple ways to do that.
First look at the html again.
   

As you can see in the image above, the second button is the 2nd link element within the div column element.

You could for example use the javascript nextElementSibling to get the object for the 2nd element.

Code:
LOCAL lcjScript
lcjScript = ''
TEXT TO lcjScript NOSHOW PRETEXT 7
() => {
       let info, row, column, link
       info = document.getElementById('information');
       row = info.firstElementChild;
       column = row.firstElementChild;
       link = column.firstElementChild;
       if (link) {
         link = link.nextElementSibling;
         link.click();
       }
     }
ENDTEXT

thisform.oAntViewDocument.RunAnonymousFunction( 1, "", lcjScript)

Getting the 3rd or 4th etc.. element would be a matter of "next next" until you reached the element of interest.
Do-able for the 3rd element I guess, but beyond that you'll get code that is hard to read/understand.

In that case it might be better to enumerate all the child objects and access them by index, by using the javascript children method.
The code then could look like this:
Code:
LOCAL lcjScript
lcjScript = ''
TEXT TO lcjScript NOSHOW PRETEXT 7
() => {
       let info, row, column, links
       info = document.getElementById('information');
       row = info.firstElementChild;
       column = row.firstElementChild;
       links = column.children;
       if (links.length>0) {
         links[1].click();
       }
     }
ENDTEXT

thisform.oAntViewDocument.RunAnonymousFunction( 1, "", lcjScript)

More VFP example code would be great and it is on our wish list, but it will probably take some more time as we are working on the control itself. But don't hesitate to ask here if you need assistance and we'll be happy to provide code snippets.

--
Wil
Reply


Messages In This Thread
VFP Web automation and form filling - by ozcan - 2023-11-07, 12:38:29
RE: VFP Web automation and form filling - by wila - 2023-11-07, 18:26:06
RE: VFP Web automation and form filling - by wila - 2023-11-24, 19:07:01
RE: VFP Web automation and form filling - by wila - 2023-11-28, 11:50:05
RE: VFP Web automation and form filling - by wila - 2023-11-08, 15:05:52
RE: VFP Web automation and form filling - by wila - 2023-11-10, 22:04:34
RE: VFP Web automation and form filling - by wila - 2023-11-13, 12:43:43
RE: VFP Web automation and form filling - by wila - 2023-11-13, 15:39:07

Forum Jump:


Users browsing this thread: 1 Guest(s)