Sign in to follow this  
Followers 0
supmah5

Click on link in a form

4 posts in this topic

Hi. I'm new to AutoIT and am trying to write a script that lets me make a booking on my gym's website. See printscreen below. I want my program to click the name of the day that is set in the script-code. I can make the program click on the menu to the left using this code:

_IELinkClickByText ($oIE, "Boka gruppaktivitet")

The problem is that the IELinkClickByText method doesn't work since the names of the weekdays are in a form (dateForm)...How do I get the program to click on for example "onsdag"? Further down I included the source code from the website, if it might be of interest.

Posted Image

Here is the source code from the website:

<form
        id="showGroupActivitiesDateForm"                 name="dateForm"           action="showGroupActivities.action"       method="POST"   >
<table class="wwFormTable">  
                <tr>
                    <td>Välj dag:</td>
                    <td valign="center" align="left">
                            <a href="javascript:change('2010-12-28')"
                               onclick="document.getElementById('showRange').checked=false; change('date', '2010-12-28'); return false;"/>&nbsp;
                            idag</a>
                            <a href="javascript:change('2010-12-29')"
                               onclick="document.getElementById('showRange').checked=false; change('date', '2010-12-29'); return false;"/>&nbsp;
                            onsdag</a>
                        
                            <a href="javascript:change('2010-12-30')"
                               onclick="document.getElementById('showRange').checked=false; change('date', '2010-12-30'); return false;"/>&nbsp;
                            torsdag</a>

Share this post


Link to post
Share on other sites



The "&nbsp" non-breaking space may be keeping the text from matching. You could get the collection of links and then loop through them using StringInStr() to find it instead.

#include <IE.au3>

; ... get ref to $oIE

$oForm = _IEFormGetObjByName($oIE, "showGroupActivitiesDateForm")
$colLinks = _IELinkGetCollection($oForm)
For $oLink In $colLinks
    If StringInStr($oLink.innerText, "onsdag") Then
        _IEAction($oLink, "Click")
        MsgBox(64, "Clicked", "Clicked link")
    EndIf
Next

:x


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You don't show the HTML source for the link you wanted to click on... _IELinkClickByText uses the .innertext property that translates nbsp into a space, so you should be able to do it without the loop. Guessing from the other links, it may be this however:

_IELinkClickByText ($oIE, " Boka gruppaktivitet")

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

You don't show the HTML source for the link you wanted to click on... _IELinkClickByText uses the .innertext property that translates nbsp into a space, so you should be able to do it without the loop. Guessing from the other links, it may be this however:

_IELinkClickByText ($oIE, " Boka gruppaktivitet")

I'm able to click the "Boka gruppaktivitet"-link. The problem for me is that next I want to click "Wednesday", but sadly that's not a link like the one to the left. "Boka gruppaktivitet" is a menuitem, and Wednesday is not a menuitem...

I'll try your solution PsaltyDS!

Share this post


Link to post
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
Sign in to follow this  
Followers 0