Jump to content

How clicking in the code <a href="javascript> using _IEAction


Recommended Posts

Hello,

I have the code that works well, opening the page and click on the links, after its not opening next link, below the code html:

<a href="javascript:__doPostBack('dtgLista$_ctl3$_ctl0','')">

I tried this code and not works:

Func ClickIncident()

$oFrame1 = _IEFrameGetObjByName($oIE, 'contents') ;OK
$oFrame2 = _IEFrameGetObjByName($oFrame1, 'main') ;OK
Local $oAreas= _IETagNameGetCollection($oIE, "href")
For $oArea In $oAreas
    if StringInStr($oArea.outerhtml,'dtgLista$_ctl3$_ctl0') <> 0 Then
        _IEAction ($oArea, "click")
        ExitLoop
    EndIf
Next

EndFunc   ;==>ClickIncident

And logs:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\cordeirs\Desktop\Projetos\AutoIT\teste moebius.au3" /UserParams    
+>20:14:15 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00000416  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409  Keyboard:00000416  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>20:14:15 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\cordeirs\Desktop\Projetos\AutoIT\teste moebius.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Found 1 area elements!
+>20:14:33 AutoIt3.exe ended.rc:0
+>20:14:33 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 17.740

Did not understand what I did wrong, Can you help me ?

Thanks

Link to comment
Share on other sites

maybe you should use

Local $oAreas= _IETagNameGetCollection($oFrame2, "href")

also, maybe is better _IELinkGetCollection instead _IETagNameGetCollection

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Hello, I tried the code change, still not working, I forgot to inform you that the code use other variables in the links, below the example:

<a href="javascript:__doPostBack('dtgLista$_ctl3$_ctl0','')">
<a href="javascript:__doPostBack('dtgLista$_ctl4$_ctl0','')">
<a href="javascript:__doPostBack('dtgLista$_ctl5$_ctl0','')"> 

I want to use the structure "for" to work the code, but I wish to use in the simple form for learning to working, below the logs:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\cordeirs\Desktop\Projetos\AutoIT\teste moebius.au3" /UserParams    
+>09:18:14 Starting AutoIt3Wrapper v.2.1.4.4 SciTE v.3.3.7.0 ;  Keyboard:00000416  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409  Keyboard:00000416  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (3.3.10.2)  from:C:\Program Files (x86)\AutoIt3
+>09:18:15 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\cordeirs\Desktop\Projetos\AutoIT\teste moebius.au3"    
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
Found 1 area elements!
+>09:18:35 AutoIt3.exe ended.rc:0
+>09:18:35 AutoIt3Wrapper Finished..
>Exit code: 0    Time: 22.186

Thanks

Link to comment
Share on other sites

  • 8 years later...

Hello Team,

I have a website with similar concept:

image.png.8f427c517066559bfa526d2bb0898930.png

 

I tried to click on "Request Number" link using below code but it did not work.

$oWebComponent = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(text(),'Request Number')]")
        
        _WD_ElementAction($sSession, $oWebComponent, "Click")

I also tried to call JavaScript but seems I do something wrong.

_WD_ExecuteScript($sSession, "__doPostBack('ctl00$PlaceHolderMain$gvDashboard','Sort$tkNum')", Default)

Could someone help me on this? Thanks in advance! 

Link to comment
Share on other sites

1 minute ago, Danp2 said:

You could try with _WD_LinkClickByText. BTW, telling us that something "doesn't work" isn't very useful without additional context. If you showed us your console output, it might help identify the reason it failed.

P.S. Next time start a new thread instead of awakening the dead. 😉

Thanks a lot for your quick help. It works with function "_WD_LinkClickByText".

I need to learn more on your recommendation "console output". I'm newbie with webdriver and Autoit.

I found this post which had similar with my problem and no final conclusion. Next time, I will open new thread.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...