7

I am trying to automate a website using WatIN IE. As the website bans the ip after few request .So I am setting a bool ipbanned =true when ip gets bannned. In that case and i wish to change the IP. The SetProxy method successfully changes the ip adress with port. but on next request I am getting this screen :-

alt text Note: - the first red strip shows the ip address and the second one shows the server name

How should I set the username and password in this dialog box from within the program, so that user do not get to see this box and it is set correctly

Below is the code snippet I am using:-

    private void Start_Thread()
    {
        Thread pop = new Thread(populate);
        pop.SetApartmentState(ApartmentState.STA);
        pop.Start();

    }
    bool ipbanned=false;
    private void populate()
    {

            if(ipbanned)
                SetProxy(proxies[0]);

           ///I wish to handle the dialog box here.

            WatiN.Core.Settings.MakeNewIeInstanceVisible = false;
            WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false;
            using (IE browser = new IE(URLs.mainurl))
            {
                    ///code
            }
    }
    private void SetProxy(string proxy)
    {
        //code which successfully changes the ip address.

    }

Any help will be deeply appreciated. Thank You :)

Ankush Roy
  • 1,621
  • 2
  • 15
  • 25
  • 1
    Mighty impressive vote ring you've got going there, with [Sandeep](http://stackoverflow.com/users/422437), [Pankaj Mishra](http://stackoverflow.com/users/165107), [Ravi shankar](http://stackoverflow.com/users/157861), [sumit_programmer](http://stackoverflow.com/users/434685), [PrateekSaluja](http://stackoverflow.com/users/307989) and [shrikant.soni](http://stackoverflow.com/users/165414). Automatically upvoting your friend's questions/answers might be interpreted as a sockpuppet ring. –  Nov 26 '10 at 18:19
  • !!!! whats automatially there....? nd are you suggesting that the questions or the answers are substandard or do not deserve upvotes. I may sound rude but it would be great to know the process – Ankush Roy Nov 27 '10 at 07:12

1 Answers1

1

You have to use AddDialogHandler to handle the dialog boxes.

You can refer the SO question watin-logondialoghandlers-not-working-correctly-in-windows-7 for code samples

Community
  • 1
  • 1
RameshVel
  • 64,778
  • 30
  • 169
  • 213
  • Hi Ramesh, Thanks for replying but through that code I was not able to handle the windows security dialog. Could not think of a way actually to set username, password and then tick the check box and click ok – Ankush Roy Nov 25 '10 at 10:48
  • @Ankush, in the sample, they are trying to retrive the Login field. i assume that works fine in earlier windows versions. You can try insetad "user name". – RameshVel Nov 25 '10 at 10:56
  • @Ankush, i have upaded the link which is dealing with the problem. you can try that – RameshVel Nov 25 '10 at 10:58