Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - liuwei0622

Pages: [1]
1


Above is one 'time table' on web page, some items are enable and some are disabled. After I select(mouse left click) one of available time(e.g. 8:30am), then the corresponding 'onClick' event will be invoked. Now I can get the 'webBrowser' object in c#, if I can simulate the selection action via webBrowser?  Below is the code snap shot:
corresponding html code:
Code: [Select]
<div id="timetableZone" style="position: relative; height: 100%;"> <table class="rms_timeSelPick"> <tbody> <tr class="rms_timeSelTitle"> <th class="rms_mon"><div><span class="d">-</span></div></th> <th class="rms_tue"><div><span class="d">-</span></div></th> <th class="rms_wed"><div><span class="d">-</span></div></th> <th class="rms_thu"><div><span class="d">-</span></div></th> <th class="rms_fri"><div><span class="d">-</span></div></th> <th class="rms_sat"><div><span class="d">-</span></div></th> <th class="rms_sun"><div><span class="d">-</span></div></th> </tr> <tr id="rms_timeSel_830" class="rms_timeSel_830"> <td id="rms_mon_830" class="rms_mon"><a href="javascript:;">8:30 am</a></td> <td id="rms_tue_830" class="rms_tue"><a href="javascript:;">8:30 am</a></td> <td id="rms_wed_830" class="rms_wed"><a href="javascript:;">8:30 am</a></td> <td id="rms_thu_830" class="rms_thu"><a href="javascript:;">8:30 am</a></td> <td id="rms_fri_830" class="rms_fri"><a href="javascript:;">8:30 am</a></td> <td id="rms_sat_830" class="rms_sat"><a href="javascript:;">8:30 am</a></td> <td id="rms_sun_830" class="rms_sun"><a href="javascript:;">8:30 am</a></td> </tr> <tr id="rms_timeSel_200" class="rms_timeSel_200"> <td id="rms_mon_200" class="rms_mon"><a href="javascript:;">2:00 pm</a></td> <td id="rms_tue_200" class="rms_tue"><a href="javascript:;">2:00 pm</a></td> <td id="rms_wed_200" class="rms_wed"><a href="javascript:;">2:00 pm</a></td> <td id="rms_thu_200" class="rms_thu"><a href="javascript:;">2:00 pm</a></td> <td id="rms_fri_200" class="rms_fri"><a href="javascript:;">2:00 pm</a></td> <td id="rms_sat_200" class="rms_sat"><a href="javascript:;">2:00 pm</a></td> <td id="rms_sun_200" class="rms_sun"><a href="javascript:;">2:00 pm</a></td> </tr> <tr id="rms_timeSel_245" class="rms_timeSel_245"> <td id="rms_mon_245" class="rms_mon"><a href="javascript:;">2:45 pm</a></td> <td id="rms_tue_245" class="rms_tue"><a href="javascript:;">2:45 pm</a></td> <td id="rms_wed_245" class="rms_wed"><a href="javascript:;">2:45 pm</a></td> <td id="rms_thu_245" class="rms_thu"><a href="javascript:;">2:45 pm</a></td> <td id="rms_fri_245" class="rms_fri"><a href="javascript:;">2:45 pm</a></td> <td id="rms_sat_245" class="rms_sat"><a href="javascript:;">2:45 pm</a></td> <td id="rms_sun_245" class="rms_sun"><a href="javascript:;">2:45 pm</a></td> </tr> <tr id="rms_timeSel_330" class="rms_timeSel_330"> <td id="rms_mon_330" class="rms_mon"><a href="javascript:;">3:30 pm</a></td> <td id="rms_tue_330" class="rms_tue"><a href="javascript:;">3:30 pm</a></td> <td id="rms_wed_330" class="rms_wed"><a href="javascript:;">3:30 pm</a></td> <td id="rms_thu_330" class="rms_thu"><a href="javascript:;">3:30 pm</a></td> <td id="rms_fri_330" class="rms_fri"><a href="javascript:;">3:30 pm</a></td> <td id="rms_sat_330" class="rms_sat"><a href="javascript:;">3:30 pm</a></td> <td id="rms_sun_330" class="rms_sun"><a href="javascript:;">3:30 pm</a></td> </tr> </tbody> </table>
JavaScript on click event code:
[code]
//setup timetable (function(){ var timetable = dojo.query('.rms_timeSelPick')[0]; dojo.query('#timetableZone').attr('aria-live','polite'); //add onclicks to links in tables dojo.query(timetable).query('a').forEach(function(node, index, array){ dojo.connect(node,'onclick',function(e){ if(dojo.hasClass(node,'available')){ dojo.query(timetable).query('.selected').removeClass('selected').attr('aria-checked','false'); dojo.query(node).addClass('selected'); dojo.query(node).attr('aria-checked','true'); var list = dojo.query(timetable).query('.available') for(var time = 0; time < list.length; time++){ var cell = dojo.query(list[time]); if (dojo.hasClass(cell[0], 'selected')) { cell.attr('tabindex', '222'); } else { cell.attr('tabindex', '221'); } } var t = dojo.query(node).attr('value'); dijit.byId('selectedDateTime').attr('value', t[0]); //enable the next button dijit.byId('nextButtonTimeslot').setDisabled(false); } }); });
I noticed there is hyperlink on each item like this:
[font=monospace][size=medium]<td id[/font][/size]="rms_thu_830" class="rms_thu">[font=monospace][size=medium][b]<a [/b][b]href[/b][/font][/size][b]="[/b][b]">[/b][color=#000000][font=monospace][size=medium]8:30 am[/color][/font][/size][font=monospace][size=medium]</a>[/font][/size][font=monospace][size=medium]</td>[/font][/size][color=#000000][font=monospace][size=medium] [/color][/font][/size]
if I can invoke the href in c# webBrowser to trigger the corresponding onClick event in JavaScript?[color=#000000][font=monospace][size=medium] so that I can implement the simulation mouse left click action. Thanks in advance.[/color][/font][/size]

2
thanks for your response. I can get the variable using below code (using mshtml)

IHTMLDocument2 vDocument = this.webBrowser1.Document.DomDocument as IHTMLDocument2; IHTMLWindow2 vWindow = (IHTMLWindow2)vDocument.parentWindow;
Type vWindowType = vWindow.GetType();
object testText = vWindowType.InvokeMember("timeslots",
                    BindingFlags.GetProperty, null, vWindow, new object[] { });

but how can I parse the testText to get the value? the type is MarshalByRefObject.
does anyone know it? Thanks.

3
I am not very understand, could you pls give me more information? Thanks

4
Hi guys, I met this problem, any help is appreciate. thanks.

How can I get the var of Java Script from c# webBrowser? 
Below is part code of the html, the function in JS does not have name.

<script type="text/javascript">
dojo.require("myrta_tbs_dojo.portlethelper.chooseTime");
var portletHelper_ns_Z7_0HEPVU271835D0IFC7B1OP10Q2_;
var containsPreferredDate = false;
var containsSelectedDate = true;
var weekDate = new Date('Mon Nov 25 00:00:00 EST 2013');
var timeslots = { "ajaxresult" : { "slots" : {
  "nextAvailableDate" : "27/11/2013 14:50",
  "listTimeSlot" : [ {
    "startTime" : "25/11/2013 8:35",
    "availability" : false,
    "slotNumber" : null 
  }, {
    "startTime" : "01/12/2013 15:35",
    "availability" : false,
    "slotNumber" : null
  } ]
}}};
var stSelectedSlot = '2013/11/28 08:35';
var timetableInterval = [515, 890, 935];
var extendedRangeFlag = false;
 
dojo.addOnLoad( function() {
  portletHelper_ns_Z7_0HEPVU271835D0IFC7B1OP10Q2_ =
      new myrta_tbs_dojo.portlethelper.chooseTime({portlet: portlet_ns_Z7_0HEPVU271835D0IFC7B1OP10Q2_});
 
    dojo.require("myrta_tbs_dojo.portlethelper.chooseLocation");

how can I get the value of timeslots in c# code via WebBrowser? thanks.

5
I met another problem,  any help is appreciate .

How can I get the var of Java Script from c# webBrowser? 
Below is part code of the html, the function in JS does not have name.

<script type="text/javascript">
dojo.require("myrta_tbs_dojo.portlethelper.chooseTime");
var portletHelper_ns_Z7_0HEPVU271835D0IFC7B1OP10Q2_;
var containsPreferredDate = false;
var containsSelectedDate = true;
var weekDate = new Date('Mon Nov 25 00:00:00 EST 2013');
var timeslots = { "ajaxresult" : { "slots" : {
  "nextAvailableDate" : "27/11/2013 14:50",
  "listTimeSlot" : [ {
    "startTime" : "25/11/2013 8:35",
    "availability" : false,
    "slotNumber" : null 
  }, {
    "startTime" : "01/12/2013 15:35",
    "availability" : false,
    "slotNumber" : null
  } ]
}}};
var stSelectedSlot = '2013/11/28 08:35';
var timetableInterval = [515, 890, 935];
var extendedRangeFlag = false;
 
dojo.addOnLoad( function() {
  portletHelper_ns_Z7_0HEPVU271835D0IFC7B1OP10Q2_ =
      new myrta_tbs_dojo.portlethelper.chooseTime({portlet: portlet_ns_Z7_0HEPVU271835D0IFC7B1OP10Q2_});
 
    dojo.require("myrta_tbs_dojo.portlethelper.chooseLocation");

how can I get the value of timeslots in c# code via WebBrowser? thanks.

6
Excellent !! It work fine when i use the form id to submit . Thank you  ;D

7
I am trying to develop one tool which can auto log on to the site:
https://www.myrta.com/wps/portal/extvp/myrta/licence/tbs/tbs-change/
After I entered valid 'Booking number' and 'Family name', the state of 'Continue' button will switch to 'enabled', then once I click the 'Continue', it will go to next page.
here is my code:
Code: [Select]
private void btnSet_Click()
         {
            int X = 300;
            int Y = 757;
             SetCursorPos(X, Y);
             Thread.Sleep(5000);
             mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
             mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), 0, 0, 0, IntPtr.Zero);
             Thread.Sleep(5000);
         }

My question is i have found the mouse cursor postion just like X = 300 & Y = 757.  i call btnSet_Click() in webBrowser1_DocumentCompleted() like below:
 
Code: [Select]
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
         {
            string pathAndQuery = e.Url.PathAndQuery;
             if (pathAndQuery.IndexOf("myTests/SelectionHandle.do") != -1)
             {
                 // fill the Account information in current web
                 this.fillTestAccount();
                  Thread.Sleep(1000);
                  this.btnSet_Click();
             }
        }

The mouse cursor have move to the appointed position(button).but the click event  is not useful for the button.. I have test the mouse event code  in another test program  . It's fine. I do not know the reason for this issue.

Here is my question:
In my tool, I can simulate to fill in the values of 'Booking number' and 'Family name' automatically, but how can I simulate to click 'continue' button? The 'Continue' button was placed in the website page, I can get the pixel location of the 'Continue' button, I know it's position exactly, I want to simulate the 'mouse left click event' to click the button,  but it does not work against this website.
I tried 'mouse left click event' function in my code against another website, it works fine.  But when I invoked the code in the method  webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e), it does not work.
 
Could you please kindly give me a sample to how to implement the 'mouse left click' function, so that the button in the website page can be triggered? Thanks in advance. In addition, I have to explain why did I choose the mouse operate to auto login instead of the other way, although below code is simpler and easier,
I have tested the www.bing.com web page using below code:
 
Code: [Select]
private void button1_Click(object sender, EventArgs e)
 {
 this.webBrowser1.Navigate("www.bing.com");
 }
 
 private void button2_Click(object sender, EventArgs e)
 {
 this.webBrowser1.Document.GetElementById("dhp").InvokeMember("onclick");
 }



When I click button1, it will navigate to the page and when I click the button2, it will run the script successfully.
But in my case, I can get the id attribute of the 'continue' button, but can not get the "click" or "onclick" operation in script. See detail info in below:
 
Code: [Select]
<!-- button -->
 <div class="rms_buttonRowStandard rms_btnSmall">
 <button dojoType="dijit.form.Button" type="submit" id="submitNoLogin"
 class="rms_initDisable rms_submit rms_btnSmall" tabindex="225">
 Continue
 </button>
 <>

 So I have to choose the mouse operate to simulate auto login. Any suggestion is appreciate. Thanks again.   ;)

Pages: [1]