Posts: 47
Threads: 17
Joined: Sep 2005
Hi,
I need QM to find and click several links on a web page, the links start all with the same string of chars like "DeflautLink" then some other text follows.
I`d like QM to find text "DeflautLink" click it then find this text again below click it and again...
How do i do it? Do i have to use htm command or just find text, get mouse pointer and click those coordinates?
Thanks,
Posts: 11,901
Threads: 138
Joined: Dec 2002
Usually when you click a link you get new page. If these links don't open a new page, can be used this code:
Htm el=htm("BODY" "" "" "+IEFrame" 0 0 0x20) ;;get BODY element which is container for all visible elements
MSHTML.IHTMLElement2 el2=+el.el ;;get IHTMLElement2 interface because we need getElementsByTagName function
MSHTML.IHTMLElement el3
foreach el3 el2.getElementsByTagName("A") ;;enumerate hyperlinks and anchors
,str linktext=el3.innerText ;;get link text
,if(!linktext.len) continue
,out linktext ;;remove this
,if(linktext.beg("DeflautLink"))
,,el3.click
Similar code also can be used to check all checkboxes.
Posts: 16
Threads: 3
Joined: Apr 2007
I have a similar problem: I need to find all of the links in a web page that have a certain string in the page that they would bring up if I pushed them. I don't actually need to click the links, just to find out what page they would bring up if I did push them.
I couldn't make Gintaras' code work. I get an "unexpected identifier" error at this line:
MSHTML IHTMLElement2 el2=+el.el
What should I do?
Posts: 16
Threads: 3
Joined: Apr 2007
Oops, never mind. I didn't see the dot after "MSHTML" and it makes much more sense with the dot.
I guess my eyes are going, but my brain is still OK.
Posts: 1,769
Threads: 410
Joined: Feb 2003
maybe it's the 'coding at midnight'? :wink: