I am trying to autologin into facebook using javascript and iam using awesomium as webcontrol in my c# application which can execute javascripts.i need the right javascript to autofill both textbox and click the login button
URL:https://www.facebook.com/login
string pass="password";
string email="example#example.com";
webControl1.ExecuteJavascript("document.getElementById('email').value="+email);
webControl1.ExecuteJavascript("document.getElementById('pass').value="+pass);
webControl1.ExecuteJavascript("document.getElementsByName('u_0_1').click()");
but its not working can anyone figure this out
Your setting the same email field twice. Try...
webControl1.ExecuteJavascript("document.getElementById('email').value="+email);
webControl1.ExecuteJavascript("document.getElementById('pass').value="+password)
webControl1.ExecuteJavascript("document.getElementById('u_0_n').click()");
I'm not sure if password is the correct id, you'll have to inspect the element yourself.
Related
I need to parse html code of tp-link router control panel page (tplinklogin.net)in order to get traffic statistics. The problem is that I can't parse the html until authentication in pop-up window is done. How do I fill this form and press "Log In" using C# so then I could parse the html?
You can use webBrowser object, I am using google as an example here .
webBrowser1.Navigate("http://www.google.com");
Next you will use ID to get elements and can call events as follows
webBrowser1.Document.GetElementById("id").InvokeMember("click");
i have used windows.history.back() to return user to previous page. now this command is not working but when i put debugger and do debug then page is getting redirect to previous page. but without debugging in firebug it is not working .
i have also tried windows.go(-1). and even i tried all this option after clearing cache. still not working
can anyone tell me what is problem? or give me alternative way to get browser back button functionality using java script/J Query or asp.net c#.
just try to use html button instead of asp.net button or put return false at the end of javascript
may be server side click is being called
You can use C# Coding also for it.
On Button click
if (Request.UrlReferrer != null)
{
Response.Redirect(Request.UrlReferrer.ToString());
}
Which control are you using to write code to previous page.
If you're using Asp:Button
write the javascript code on onclientclick event
window.history.go(-1)
If you're using Html button
write the javascript code on onclick event
window.history.go(-1)
If you're using anchor tag <a>
write the javascript code to href attribute
<a href="javascript:window.history.go(-1);">
Try this
onclick="window.history.go(-1)"
I want to get text from a website, but from a certain element, does any one have any clues?
From example the code I have to make text form a text box to a website textbox is
webBrowser1.Document
.GetElementById("MySchool_login")
.SetAttribute("value", textBox1.Text);
What you want to do is called as screen scrapping. You can use Watin for this. Or else you can use WebResponse and WebRequest to achieve this also.
I need help with connecting to a certain website via my username & password.
With WebClient I can fill the username field and the password field, but how do I invoke the click method of the button?
And How can I fill a specific textBox that doesn't have an ID?
I tried doing this with webBrowser, but every time I navigate I have to use a new function every time, which makes the work much harder.
Thanks.
What you're trying to do is wrong. If you want to Post some data to a web address (a URL), simply create a web form (a simple HTML form), fill it, and then send it. Just consider these notes:
Your HTML's form action should be the exact URL of the form you're imitating.
Your input controls should have the same name attribute value.
For more information, see Form Spoofing
Look at the web browser control and see if you can use that inside your windows form to perform the task that you are doing. Once you are satisfied with the results, you can make the web browser control invisible, and it'll work just like you do with web response and request calls.
View the source code and find the id of the button (say "Login").
Then use:
HtmlElement elem = webBrowser1.Document.GetElementById("Login");
if (elem != null)
elem.InvokeMember("click");
I am designing a winforms based testing app (which is based upon WatiN). I specify a page to test and the value to insert into a textbox, and then click the corresponding button.
Is it possible to add a query string to the request I make (when clicking button) and then get the URL of the next page? Based on this, I need to screen scrape it.
Not sure about Watin syntax, but in Watir (Ruby version) you can get URL of the page displayed in browser with
browser.url
Or do you need to get URL of the next page before you open it?
Based on your comment to AmitK, Ċ½eljko's answer is right.
In WatiN (and C#), the syntax is:
Console.WriteLine("The current page is:" + ie.Url.ToString());
(just in case: 'ie' is the browser reference, use whatever object you use to enter text and click buttons)
What exactly do you mean by "next page" ? Does the form when submitted redirect to another page? If so, you will receive a HTTP 302/303 status code with the URL of the next page.