dimanche 19 février 2017

VB.NET WebBrowser Logging in website failure

I did look into tutorials obviously but the html I have is different and I tried a lot of things (the code I will post is the last thing I tried). I will provide you with the html too.

   WebBrowser1.Navigate("THE_WEBSITE")
    WebBrowser1.Document.GetElementById("tbtLoginID").SetAttribute("onfocus", "javascript:$(this).val('ID_GOES_HERE');$('#wrong_password_board').css('display','none');")
    WebBrowser1.Document.GetElementById("tbtPassword").SetAttribute("value", "PASS_PROBABLY_GOES_HERE")
    WebBrowser1.Document.GetElementById("div_123").SetAttribute("onpress", "rockLogin($('#loginform'))")'

And this is the HTML (I think it's everything that matters, the website is www.microvolts.com anyway)

<form id="loginform" action="/Account/login" method="POST">
        <div class="left1"> </div>
        <div class="login_info1">
            <div class="icon_rh">
            </div>
            <div class="floatleft" style="margin-bottom: 2px;">
                <input id="tbtLoginID" width="110px" maxlength="25" height="17px" class="text_box" value="Login ID" tabindex="1" onfocus="javascript:$(this).val('');$('#wrong_password_board').css('display','none'); "> 
            </div>
            <div class="floatleft">
                <div id="loginLoginIdDiv1">
                    <input type="text" onfocus="javascript:$(this).val('');$('#wrong_password_board').css('display','none'); " value="Password" tabindex="2" class="text_box" name="passwordFaked" size="20" width="110px" style="display: none;">
                    <div id="loginPasswordDiv2" style="">
                        <input id="tbtPassword" width="110px" type="password" tabindex="2" maxlength="25" height="17px" class="text_box"> 
                    </div>
                </div>

                <div id="wrong_password_board" class="wrong_password wrong_passwordid ErrorMsg" style="display: none;">
            <div class="topleft"></div>
            <div class="topmiddle">Invalid Login ID and/or Password.</div>
            <div class="topright"></div>
        </div>
            </div>
        </div>
        <div class="login_info2">
            <div class="row1">
                <a href="javascript:void(0);" onclick="fbConnect();" class="login_facebook"><span class="left"></span><span class="middle">Login</span><span class="right"></span></a>
            </div>
            <div class="row1" style="width: 80px">
                <span style="float: left; margin-right: 3px;">
                    <div id="div_123" class="toplogin RockButton" style="width: 60px; height: 19px;">
                        <div id="123" onclick="rockLogin($('#loginform'))" style="width: 100%; height: 100%;" class="rbtdiv">
                            <div class="text">
                                Login</div>
                        </div>
                        <div class="rbtmask" style="z-index: 100; position: absolute; display: none; background: grey;
                            opacity: 0.2; cursor: default; width: 100%; height: 100%; top: 0px; left: 0px;">
                        </div>
                    </div>
                </span>
                <div class="btn_question forgetPasswordButton ">

                    <div id="ifClickThisBtn" style=" display:none;" data-ifclick="false"></div>
                </div>
                <div id="forgetPassword" class="tip_forgot_password">
                            <div class="ajaxLoadingMask">
                                <img src="/images/ajaxLoading2.gif" style="margin-left: 150px; margin-top: 9px; position: absolute; display: block;" class="ajaxLoading" alt="">
                            </div>
                            <div class="lefttfp">
                                <div class="l1l"></div>
                                <div class="l1r"></div>
                            </div>
                            <div class="middletfp">
                                <div class="closetfp"></div>
                                <div class="title">Forgot Password or Login ID</div>
                                <div class="email_form">
                                    <input type="text" value="Enter registered email" name="emailAddress" class="password_recovery_textbox">

                                    <div class="wbtn1 formSubmitBtn" onclick="javascript:forgetPassword();return false;" style="float: left; margin: 2px 0px 0px 5px; cursor: pointer;">
                                   <span class="wbtn1_left"></span><span class="wbtn1_middle" style="padding-left: 10px;
                                    padding-right: 10px;">Submit</span><span class="wbtn1_right"></span></div>
                                    <div class="wrong_email"></div>
                                </div>
                                <div id="invalideEmailAddress" style="display:none;"> Please enter a valid email address.</div>
                            </div>
                            <div class="righttfp"></div>
                        </div>
            </div>
        </div>
        <div class="right1"> </div>

        </form>

The login form has javascript elements so I figured I could just write it with the right login into it, but nah. When I run it I get an error from the first line: System.NullRefferenceException, all my codes gave that.

I have to admit I probably didn't do all the research I could but I need to do this fast and this is the last thing that may help me.




Aucun commentaire:

Enregistrer un commentaire