Jump to content

Buttons with no form name or button name.


mianz
 Share

Recommended Posts

<TR>

<TD align=CENTER WIDTH="50%">

<input type="button" value="I Agree" class="btn" onmouseover="blueBtnOver(this)" onmouseout="blueBtnOut(this)" onclick="java script:location.href='b-3c-SelectPracticalTestBooking.asp?+3'"/>

</TD>

<TD align=CENTER WIDTH="50%">

<input type="button" value="Disagree" class="btn" onmouseover="blueBtnOver(this)" onmouseout="blueBtnOut(this)" onclick="java script:location.href='b-default.asp'"/>

</TD>

</TR>

This is all i'm given. i have obsolutely no idea how to click on that button. i do not wish to use coordinates. Can any professional please help me. thanks a millon.

Link to comment
Share on other sites

<TR>

<TD align=CENTER WIDTH="50%">

<input type="button" value="I Agree" class="btn" onmouseover="blueBtnOver(this)" onmouseout="blueBtnOut(this)" onclick="java script:location.href='b-3c-SelectPracticalTestBooking.asp?+3'"/>

</TD>

<TD align=CENTER WIDTH="50%">

<input type="button" value="Disagree" class="btn" onmouseover="blueBtnOver(this)" onmouseout="blueBtnOut(this)" onclick="java script:location.href='b-default.asp'"/>

</TD>

</TR>

This is all i'm given. i have obsolutely no idea how to click on that button. i do not wish to use coordinates. Can any professional please help me. thanks a millon.

You might find looking in the help file for _IEAction or _IEFormSubmit to be useful.

Link to comment
Share on other sites

Oops! Pardon, I see your point.

Other than using unreliable coordinates the only thing I can think of would be the brute-force approach of sending keystrokes to the window, like:

Send("{TAB}{TAB}{TAB}{ENTER}")

Maybe a true guru knows of a better method.

Link to comment
Share on other sites

In addition, you may need _IEFormElementGetCollection or _IETagnameGetCollection

There are lots of ways to do this... here is one:

$oInputs = _IETagnameGetCollection($oIE, "input")
For $oInput in $oInputs
    If $oInput.type = "button" and String($oInput.value) = "I Agree" Then _IEAction($oInput, "click")
Next

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

Link to comment
Share on other sites

After i click on a submit button, there comes a popup asking me for a OK or Cancel click. i tried this command.

WinWait("Windows Internet Explorer")

ControlClick("Windows Internet Explorer", "", "[CLASS:Button; Instance:1;]") <--- last line

It didnt work. funny thing is after i manually click cancel, the script is still running at this moment. then i try to click a logoff link, which also prompt the same popup box, now it automaticly click cancel for me, and the script would end.

why is this so?

Link to comment
Share on other sites

i found out why already.

WinWait("Windows Internet Explorer")

ControlClick("Windows Internet Explorer", "", "[CLASS:Button; Instance:1;]")

this command actually works, is due to the previous command

_IEFormSubmit ($oForm2)

i have change to

_IEAction ($oSubmit2, "click")

now it works fine? i'm surpise. why is that so too.

Link to comment
Share on other sites

I'm not certain I am understanding completely your problem.

One thing that can happen is that clicking on a button can cause a Javascript alert box or message window to appear. If this happens, your script is likely to pause until the message box is dismissed... this prevents your program from dismissing it because it does not have control.

If this is happening to you, you can use the technique in Example 2 for _IEAction in the helpfile

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

Link to comment
Share on other sites

i'm just surpise why _IEFormSubmit ($oForm2) didn't work and _IEAction ($oSubmit2, "click") would work.

is there anyway that i can select on this radio button which do not have a form name, and i wan to select it via searching for this value only ---> 18/10/2008

the radio button value is random, so i couldt use that.

<td id='cell58_1' class='txtbold' align='center' bgcolor='white' onmouseover='doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");' onmouseout="hideTip();"><input type="radio" id="58_1" name="slot" value="142233"></td>

Link to comment
Share on other sites

<td id='cell58_1' class='txtbold' align='center' bgcolor='white' onmouseover='doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");' onmouseout="hideTip();">

<input type="radio" id="58_1" name="slot" value="142233"></td>

$elements = $ie.document.getElementsByTagName("input")

For $element in $elements

If $element.previousSibling.getAttribute("onmouseover") = "'doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");' Then

$element.Click()

endif

Next

or maybe like this

...

If $element.parentNode.firstChild.getAttribute("onmouseover") = "'doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");' Then

...

do something like that, i can't be sure because i don't know what the page looks like

once you get away from the ie.au3 functions you open yourself up to alot of flexibility for navigating the DOM

Link to comment
Share on other sites

If $element.previousSibling.getAttribute("onmouseover") = "'doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");'" Then

If $element.previousSibling.getAttribute("onmouseover") = "'doTooltip(event,0, "18/10/2008 (Sat^ ERROR

isnt the previoussibling this ----> onmouseout="hideTip();"

sorry i'm confused

Link to comment
Share on other sites

you'll need to use escape characters so that the whole thing becomes a string, right now it thinks its code

somenode.previousSibling returns the DOM node which is 1 above the given node...

so suppose i have like this

<div images>

<img1....

<img2...

<img3...

</div>

then img2.parentNode is going to be the div, and img2.previousSibling is going to be img1, while img2. nextSibling is going to be img3

Link to comment
Share on other sites

<tr bgcolor='#FFFFFF'><td class='txtbold' align='center'>18/10/2008<BR>Sat</td><td></td><td id='cell58_1' class='txtbold' align='center' bgcolor='white' onmouseover='doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");' onmouseout="hideTip();"><input type="radio" id="58_1" name="slot" value="142233"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>

this is the full line of codes. does it help? sorry for needing a spoon feed. got really no idea.

Link to comment
Share on other sites

<tr bgcolor='#FFFFFF'>
    <td class='txtbold' align='center'>18/10/2008<BR>Sat</td>
    <td></td>
    <td id='cell58_1' class='txtbold' align='center' bgcolor='white' onmouseover='doTooltip(event,0, "18/10/2008 (Sat)","2","09:15","09:45");' onmouseout="hideTip();"><input type="radio" id="58_1" name="slot" value="142233"></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
</tr>

can be found by taking an approach like this

$elements = $ie.document.getElementsByTagName("td")
for $element in $elements
    if $element.outerText = "18/10/2008" then
          $element.nextSibling.nextSibling.Click()
     endif
Next

or if it will always have the id=58_1 then you can do

$ie.document.getElementById("cell58_1").Click()

not 100% sure about the click command, but finding the object is the hard part

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...