• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

IE and VBA radio button selection

Hi Experts

I need help to automate webpage

I am trying to select radio buttons and select value in selectCls but facing problem with my code please help me on the same

Thanks in advance..


My code is
Code:
Browser.document.getElementById("ddlCycleID").SelectCls = "Cycle 274 (21 Jun 2017 - 31 Jul 2017)"
Browser.document.getElementById("chkproc").Checked = True
Browser.document.getElementById("btnSubmit").Click

HTML Source code is

Code:
<td>
<input value="chkproc" name="Module" type="radio" id="chkproc" checked="checked" tabindex="1" onclick="toggle(this)">&nbsp;Processing Module                                    
<td>

<td>
<input value="chkquery" name="Module" type="radio" id="chkquery" tabindex="2" onclick="toggle(this)">&nbsp;Other Modules
<td>

<td>
<select name="ddlCycleID" id="ddlCycleID" tabindex="4" class="SelectCls" style="width:180px;">
    <option value="Select Cycle">Select Cycle</option>
    <option value="274">Cycle 274 (21 Jun 2017 - 31 Jul 2017)</option>
    <option value="273">Cycle 273 (29 Jun 2017 - 29 Jun 2017)</option>

</select>
<td>
 
Last edited:
Hi Hui,

Hope your doing well..Thanks for your reply.

this is the first post..later i cross posted the same in other website and mentioned that this is corss post and pasted this url over there..i know the rules thats the reason i have mentioned that this is a cross post in other website..

In my earlier posts also i have clearly mentioned whenever i did cross post and provided the related links for the same.


https://chandoo.org/forum/threads/ie-and-vba-radio-button-selection.35633/#post-213424..
 
Last edited:
Ok, here's the issue.

For drop down...
Code:
Browser.document.getElementById("ddlCycleID").SelectCls = "Cycle 274 (21 Jun 2017 - 31 Jul 2017)"

1. You are trying to set value using innerText of the element.
2. "SelectCls" is not valid property or method.

Should be something like...
Code:
Browser.document.getElementById("ddlCycleID").selectedindex = 1

For Radio button. Looking at HTML, by default "chkproc" is checked. So no need to check it by code.

Edit: FYI it's far easier to trace what request(s) are sent to the sever using developer tool. Then use the parameter sent to write code using XMLHttp / WinHttp. Instead of piloting IE.
 
Hi Chihiro


Thanks for your reply..


Code:
 Browser.document.getElementById("ddlCycleID").selectedindex = 1

I Have tried this code also but getting error ‘Run-time error “424” / Object required’



Below is the code which is working fine till arriving this page.

Code:
Sub KBOSS()


Set Browser = CreateObject("internetexplorer.application")

Browser.Visible = True



Browser.navigate ("https://backoffice.karvymfs.com/backoffice/Login.aspx")



Do

DoEvents

Loop Until Browser.readystate = 4


Browser.document.getElementById("txtUserId").Value = "Username"

Browser.document.getElementById("txtPassword").Value = "password"

Browser.document.getElementById("selFund").selectedindex = "26"

Browser.document.getElementById("btnSubmit").Click




Do

DoEvents

Loop Until Browser.readystate = 4




---Stucked at this code : Browser.document.getElementById("ddlCycleID").selectedindex = "1"---



(Edit: FYI it's far easier to trace what request(s) are sent to the sever using developer tool. Then use the parameter sent to write code using XMLHttp / WinHttp. Instead of piloting IE.) >>Thank you..
 
Last edited:
When working with web scraping, especially when using getElementById, it is recommended that you add reference to appropriate library(ies).

As in, MS HTML Object library & MS Internet Controls etc.
Without it, there are some property/method that behaves oddly.

Also your Do Events Loop isn't ideal. While it will work most of the time, it will fail to wait on some instances.

Code:
Do

DoEvents

Loop Until Browser.readystate = 4

You should check for... .readyState <> 4 and .Busy

So something like.
Code:
While Browser.readyState <> 4 Or Browser.Busy: DoEvents: Wend
 
Hi Chihiro

Code:
While Browser.readyState <> 4

This code is working perfectly:awesome:..Thanks a lot for the help...

I will keep post if i face any difficulty in my current project..please help me on the same.


Thanks in advance.
 
Last edited:
Hi Chihiro,
Hope yor doing well..

I stucked at below code..Please help me on the same.

Im trying to select an option from "onmouseover" Vertical Menu.

VBA:
Code:
 Browser.Document.getElementById("ctl00_OthersMenun2").selectedindex = "4"

Code:
<td onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(event)" id="ctl00_OthersMenun1">

<table class="VerticalMenu ctl00_OthersMenu_4" cellpadding="0" cellspacing="0" border="0" width="100%">

<tbody><tr>

<td style="white-space:nowrap;">

<a class="ctl00_OthersMenu_1 VerticalMenu ctl00_OthersMenu_3" href="javascript:__doPostBack('ctl00$OthersMenu','2')" style="border-style:none;font-size:1em;">Report Module

</a>

</td>

<td style="width:0;">

<img src="/kbossuti/WebResource.axd?d=QcLzkQeYzhF8RucJXKrO-mpv3xu59ztiQsjTEi4SuV-YOrJzR8MfYnQo1BfpALU1jdv_UKzUl8nj0ym3iJlgyS--q9k1&amp;t=635316203528827089" alt="Expand Report Module" style="border-style:none;vertical-align:middle;">

</td>

</tr>

</tbody>

</table>

</td>

Thanks in advance....
 
Don't think I can be of much help on this one without actually accessing the site and observing it's behaviour and what requests are sent.

From the looks of it, it uses java script and not entirely clear what options are presented on mouse over.
 
Hi Chihiro,
Thanks for your reply..

your right can't help without accessing the site.. its a company website which can't be accessed without employee credentials...

i can provide entire html code for that particular page.. hope that will help to understand the same.
 
Hi Chihiro,
How are you...! Hope your doing well..

Please help me on my current project.. Im facing problem with interacting with website popup message.. Have attached screenshot for your reference.

Thanks in advance.


Untitled.jpg
 
Back
Top