예제 #1
1
        /// <summary>
        /// Logins the user.
        /// </summary>
        /// <param name="browser">The <paramref name="browser"/> instance.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">The user password.</param>
        /// <returns>If User login was successfully or not</returns>
        public static bool LoginUser(IE browser, string userName, string userPassword)
        {
            // Login User
            browser.GoTo("{0}yaf_login.aspx".FormatWith(TestConfig.TestForumUrl));

            // Check If User is already Logged In
            if (browser.Link(Find.ById(new Regex("_LogOutButton"))).Exists)
            {
                browser.Link(Find.ById("forum_ctl01_LogOutButton")).Click();

                browser.Button(Find.ById("forum_ctl02_OkButton")).Click();
            }

            browser.GoTo("{0}yaf_login.aspx".FormatWith(TestConfig.TestForumUrl));

            browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            browser.TextField(Find.ById(new Regex("Login1_UserName"))).TypeText(userName);
            browser.TextField(Find.ById(new Regex("Login1_Password"))).TypeText(userPassword);

            browser.Button(Find.ById(new Regex("LoginButton"))).ClickNoWait();

            browser.GoTo(TestConfig.TestForumUrl);

            return browser.Link(Find.ById(new Regex("LogOutButton"))).Exists;
        }
예제 #2
0
        /// <summary>
        /// Screen Scrape Events
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        static List<EventDetail> FetchEvents(string query)
        {
            var eventDetails = new List<EventDetail>();
            using (var _browser = new IE("http://www.gettyimages.com", false))
            {
                _browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide);
                _browser.TextField(Find.ById("txtPhrase")).Clear();
                _browser.TextField(Find.ById("txtPhrase")).TypeText(query);
                var editorialChkfield = _browser.CheckBox(Find.ById("cbxEditorial"));

                if (!editorialChkfield.Checked)
                    editorialChkfield.Click();

                _browser.Button(Find.ById("btnSearch")).Click();

                if (_browser.Link(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_lnkSeeMore")).Exists)
                {
                    _browser.Link(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_lnkSeeMore")).Click();
                    _browser.Div(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_refinementContent")).WaitUntilExists();

                    var filterContentDiv = _browser.Div(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_refinementContent"));

                    foreach (var link in filterContentDiv.Links.Filter(Find.ByClass("refineItem")))
                    {
                        var splitList = link.OuterHtml.Split('\'');

                        if (splitList.Length > 5)
                            eventDetails.Add(new EventDetail() { EventId = int.Parse(splitList[1]), EventName = splitList[5].Trim() });
                    }
                }
            }

            return eventDetails;
        }
예제 #3
0
 public void SetUp()
 {
     Settings.WaitForCompleteTimeOut = 10;
     Settings.WaitUntilExistsTimeOut = 10;
     ie = new IE();
     ie.GoTo(url + "ProspectorPlus/VendorLogin.aspx");
     ie.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
 }
예제 #4
0
파일: Form1.cs 프로젝트: Wynncraft/WynnIR
 private void openThread_Click(object sender, EventArgs e)
 {
     var browser = new IE("forums.wynncraft.com/threads/invasion-tracker.28/page-" + a.ToString());
     browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
     string post = "There will be a swarm on Server " + server.ToString() + " in " + city.ToString() + ". ";
     if (mins != 0) { post += "It will be in " + mins.ToString() + " minutes time.";  }
     else { post += "I am unsure how long it is until it starts."; }
     Clipboard.SetText(post);
 }
예제 #5
0
        /// <summary>
        /// Registers the standard test user.
        /// </summary>
        /// <param name="browser">The <paramref name="browser"/> instance.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <returns>
        /// If User was Registered or not
        /// </returns>
        public static bool RegisterStandardTestUser(IE browser, string userName, string password)
        {
            browser.GoTo("{0}yaf_register.aspx".FormatWith(TestConfig.TestForumUrl));

            var email = "{0}@test.com".FormatWith(userName.ToLower());

            browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            // Check if Registrations are Disabled
            if (browser.ContainsText("You tried to enter an area where you didn't have access"))
            {
                return false;
            }

            // Accept the Rules
            if (browser.ContainsText("Forum Rules"))
            {
                browser.Button(Find.ById("forum_ctl04_Login1_LoginButton")).Click();
                browser.Refresh();
            }

            if (browser.ContainsText("Security Image"))
            {
                return false;
            }

            // Fill the Register Page
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_UserName"))).TypeText(
                userName);

            if (browser.ContainsText("Display Name"))
            {
                browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_DisplayName"))).TypeText(userName);
            }

            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Password"))).TypeText(password);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_ConfirmPassword"))).TypeText(password);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Email"))).TypeText(email);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Question"))).TypeText(password);
            browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Answer"))).TypeText(password);

            ////browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_tbCaptcha"))).TypeText(captcha);

            // Create User
            browser.Button(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_StepNextButton"))).Click();

            if (!browser.ContainsText("Forum Preferences"))
            {
                return false;
            }

            browser.Button(Find.ById(new Regex("ProfileNextButton"))).Click();

            return browser.Link(Find.ById(new Regex("_LogOutButton"))).Exists;
        }
예제 #6
0
        public static void NavigateToHomePage(ref IE ieBrowser)
        {
            if (ieBrowser == null)
            {
                ieBrowser = new IE();
                ieBrowser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
            }

            ieBrowser.GoTo(ConfigurationReader.getHomePageUrl() + "Default.aspx");
            ieBrowser.WaitForComplete();
        }
예제 #7
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="maxWaitInMs">The maximum number of milliseconds before the tests should timeout after page load; -1 for infinity, 0 to not support asynchronous tests</param>
 public QUnitParser(int maxWaitInMs)
 {
     _maxWaitInMs = maxWaitInMs < 0 ? Int32.MaxValue : maxWaitInMs;
     _ie = new IE();
     if (NQUnit.HideBrowserWindow)
     {
         _ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
     }
     if (NQUnit.ClearCacheBeforeRunningTests)
     {
         _ie.ClearCache();
     }
 }
        public void InteractingWithElement()
        {
            using (var browser =
                new IE("http://localhost:62727/Pages/ApplyForCreditCard.aspx"))
            {
                browser.AutoClose = false;
                browser.ShowWindow(NativeMethods.WindowShowStyle.Minimize);
                browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            TextField applicantName = browser.TextField(Find.ById("Name"));
            applicantName.TypeText("Jason Roberts");

            Link helpHyperlink = browser.Link(Find.ById("HelpLink"));
            helpHyperlink.Click();

            SelectList title = browser.SelectList(Find.ById("Title"));
            title.Select("Prof");
            title.SelectByValue("4");

            Button applyButton = browser.Button(Find.ById("ApplyNow"));
            applyButton.Click();

            }
        }
예제 #9
0
파일: WatiNUtil.cs 프로젝트: biganth/Curt
        /// <summary>
        /// Opens a new IE instance with the given settings in front of other windows that are currently open.
        /// </summary>
        /// <param name="targetURL">The URL that the IE instance should browse to.</param>
        /// <param name="silentMode">If true the test will be run without displaying any IE instance or steps.</param>
        /// <param name="timeOut">The default time out to use when calling IE.AttachToIE(findby).</param>
        /// <param name="autoCloseIE">If true when a reference to the IE instance is destroyed the actual window will close.</param>
        /// <param name="movePointer">It true the mouse pointer will move to the top left corner of the screen when a new IE instance is created.</param>
        /// <returns>The new IE instance.</returns>
        public static IE OpenIEInstance(string targetURL, bool silentMode, int timeOut, bool autoCloseIE, bool movePointer)
        {
            Settings.MakeNewIeInstanceVisible = !silentMode;
            Settings.WaitForCompleteTimeOut = timeOut;
            Settings.WaitUntilExistsTimeOut = timeOut;
            Settings.AttachToBrowserTimeOut = timeOut;
            Settings.AutoMoveMousePointerToTopLeft = movePointer;

            IE ieInstance = new IE { AutoClose = autoCloseIE };
            if(!silentMode) ieInstance.ShowWindow(NativeMethods.WindowShowStyle.ShowMaximized);
            ieInstance.BringToFront();
            ieInstance.GoTo(targetURL);

            return ieInstance;
        }
예제 #10
0
        public void SetUp()
        {
            Settings.WaitForCompleteTimeOut = 80;
            Settings.WaitUntilExistsTimeOut = 80;

            platform = (Platform)Enum.Parse(typeof(Platform), System.Configuration.ConfigurationManager.AppSettings["Platform"]);
            targetHost = System.Configuration.ConfigurationManager.AppSettings["TargetHost"];

            switch (platform)
            {
                case Platform.IE:

                    browser = new IE();
                    browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
                    break;
                case Platform.FF:
                    browser = new FireFox();
                    browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
                    break;

            }
            browser.GoTo(targetHost);
        }
예제 #11
0
 public WatinDriver(IE ie, string baseurl)
 {
     _baseurl = baseurl;
     IE = ie;
     IE.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
 }
예제 #12
0
        public static IE GetInternetExplorer()
        {
            if (_browser == null)
            {
                lock (LOCK_ROOT)
                {
                    if (_browser == null)
                    {
                        IE.Settings.AutoMoveMousePointerToTopLeft = false;

                        _browser = (IE) BrowserFactory.Create(BrowserType.InternetExplorer);
                        _browser.ShowWindow(NativeMethods.WindowShowStyle.Hide);
                    }
                }
            }

            return _browser;
        }
예제 #13
0
 public void BeforeTest()
 {
     Log = new TestContextLog(TestContext);
     _ie = new IE();
     _ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
 }
예제 #14
0
        public void WebApplicationScraping()
        {
            try
            {
                // Reads the path of the web application
                string webSitePath = Convert.ToString(ConfigurationManager.AppSettings["WebApplicationPath"]);
                string filePhysicalPath = Convert.ToString(ConfigurationManager.AppSettings["ScraperEnginePhysicalLocation"]);

                StreamWriter file = new StreamWriter(filePhysicalPath + "Output.txt");

                if (webSitePath != null && webSitePath != string.Empty)
                {
                    // Create an instance of IE browser
                    IE ieInstance = new IE(webSitePath);

                    // This will opens IE browser in maximized mode
                    ieInstance.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);

                    // Watin window will not visible to the end user when web scraping is done
                    //ieInstance.Visible = false;

                    // This will wait for the browser to complete loading of the page
                    ieInstance.WaitForComplete();

                    // This will store page source in categoryPageSource variable
                    string categoryPageSource = ieInstance.Html;

                    // Regular expression pattern to fetch list of categories categories

                    Regex categoryMatches = new Regex(_categoryRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);

                    // Fetches all the categories based upon category regex from category listing page
                    MatchCollection categoryMatchCollection = categoryMatches.Matches(categoryPageSource);

                    // Navigate to each categories and fetch page URL and navigate to the item listing page for each categories
                    foreach (Match categoryMatch in categoryMatchCollection)
                    {
                        GroupCollection categoryGroup = categoryMatch.Groups;

                        // URL of the item listing page
                        string itemListingURL = Convert.ToString(categoryGroup["href"].Value);

                        // Partial web path where demonstration web site is deployed.
                        // Note: This path needs to be modified in App.Config file accordingly.
                        string webSiteHostedLocation = webSitePath.Remove(webSitePath.LastIndexOf("/"));

                        // Creates path of the category listing page.
                        string itemListingpath = webSiteHostedLocation + "/" + itemListingURL;

                        // Navigate to the item listing page
                        ieInstance.GoTo(itemListingpath);

                        ieInstance.WaitForComplete();

                        // HTML source of given generated web page
                        string itemListingPageSource = ieInstance.Html;

                        // Match for the paging Event
                        Regex pagingMatches = new Regex(_pagingRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant | RegexOptions.Multiline);

                        // Find Matches.
                        MatchCollection pagingMatchCollection = pagingMatches.Matches(itemListingPageSource);

                        foreach (Match pageMatch in pagingMatchCollection)
                        {
                            GroupCollection pagingGroup = pageMatch.Groups;

                            if (pagingGroup[_pageNumber].Value != "1")
                            {
                                // Fetches the page number of the current page.
                                string linkText = Convert.ToString(pagingGroup[_pageNumber].Value);

                                // Performs click event on the given link. For e.g if linkText contains "2" as a value then 
                                //Watin will perform click event on this second link.
                                ieInstance.Link(Find.ByText(linkText)).Click();

                                // Wait for the operation to complete
                                ieInstance.WaitForComplete();

                                // Store the result of the page in itemListingPageSource variable
                                itemListingPageSource = ieInstance.Html;
                            }

                            Regex itemMatches = new Regex(_itemRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);

                            // Fetches all the items based upon item regex from the item listing page
                            MatchCollection itemMatchCollection = itemMatches.Matches(itemListingPageSource);

                            // Navigate to each item and fetch ProductID, ProductName and ProductPrice and store the result in text file
                            foreach (Match itemMatch in itemMatchCollection)
                            {
                                GroupCollection itemGroups = itemMatch.Groups;

                                // Fetch productId from the given item group
                                string productID = Convert.ToString(itemGroups[_productID].Value);

                                // Fetch productName from the given item Group
                                string productName = Convert.ToString(itemGroups[_productName].Value);

                                // Fetch product price from the given product price
                                string productPrice = Convert.ToString(itemGroups[_productPrice].Value);

                                file.WriteLine("ProductID: " + productID);

                                file.WriteLine("Product Name: " + productName);

                                file.WriteLine("Product Price: " + productPrice);

                                file.WriteLine("-----------------------------------------------------------------------------------------------");

                                file.WriteLine("\n");
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Mention category listing website application path");
                }

                file.Close();
            }
            catch (Exception ex)
            {

            }
            finally
            {

            }
        }
예제 #15
0
        /// <summary>
        /// Setups the Test website.
        /// </summary>
        private void SetupWebsite()
        {
            IEInstance = new IE();

            IEInstance.GoTo("{0}install/default.aspx".FormatWith(TestConfig.TestForumUrl));

            IEInstance.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            IEInstance.WaitForComplete(5000);

            // Enter Config Password
            IEInstance.TextField(Find.ById("InstallWizard_txtEnteredPassword")).TypeText(TestConfig.ConfigPassword);
            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepPreviousButton")).Click();

            IEInstance.RadioButton(Find.ById("InstallWizard_rblYAFDatabase_1")).Click();

            // Enter YAF Database Connection
            IEInstance.TextField(Find.ById("InstallWizard_Parameter1_Value")).TypeText(TestConfig.DatabaseServer);

            IEInstance.TextField(Find.ById("InstallWizard_Parameter2_Value")).TypeText(TestConfig.TestDatabase);

            // Test Database Conncection
            IEInstance.Button(Find.ById("InstallWizard_btnTestDBConnection")).Click();

            Assert.IsTrue(IEInstance.ContainsText("Connection Succeeded"), "Database Connection Is Wrong");

            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            // Test Mail Setup
            IEInstance.TextField(Find.ById("InstallWizard_txtTestFromEmail")).TypeText(TestConfig.TestForumMail);

            IEInstance.TextField(Find.ById("InstallWizard_txtTestToEmail")).TypeText("*****@*****.**");

            IEInstance.Button(Find.ById("InstallWizard_btnTestSmtp")).Click();

            Assert.IsTrue(
                IEInstance.ContainsText("Mail Sent. Verify it's received at your entered email address."),
                "Mail Send Failed");

            if (TestConfig.UseTestMailServer)
            {
                SmtpMessage mail = SmtpServer.ReceivedEmail[0];

                Assert.AreEqual("*****@*****.**", mail.ToAddresses[0].ToString(), "Receiver does not match");
                Assert.IsTrue(mail.FromAddress.ToString().Contains(TestConfig.TestForumMail), "Sender does not match");
                Assert.AreEqual(
                    "Test Email From Yet Another Forum.NET", mail.Headers["Subject"], "Subject does not match");

                Assert.AreEqual(
                    "The email sending appears to be working from your YAF installation.",
                    mail.MessageParts[0].BodyView,
                    "Body does not match");
            }

            // Now continue to Initialize Database
            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();

            // Initialize Database
            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).ClickNoWait();

            IEInstance.WaitUntilContainsText("Create Board", 300);

            Assert.IsTrue(IEInstance.ContainsText("Create Board"));

            // Board Settings
            IEInstance.TextField(Find.ById("InstallWizard_TheForumName")).TypeText(TestConfig.TestApplicationName);
            IEInstance.TextField(Find.ById("InstallWizard_ForumEmailAddress")).TypeText(TestConfig.TestForumMail);

            // Admin User
            IEInstance.TextField(Find.ById("InstallWizard_UserName")).TypeText(TestConfig.AdminUserName);
            IEInstance.TextField(Find.ById("InstallWizard_AdminEmail")).TypeText(TestConfig.TestForumMail);
            IEInstance.TextField(Find.ById("InstallWizard_Password1")).TypeText(TestConfig.AdminPassword);
            IEInstance.TextField(Find.ById("InstallWizard_Password2")).TypeText(TestConfig.AdminPassword);
            IEInstance.TextField(Find.ById("InstallWizard_SecurityQuestion")).TypeText(TestConfig.AdminPassword);
            IEInstance.TextField(Find.ById("InstallWizard_SecurityAnswer")).TypeText(TestConfig.AdminPassword);

            IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).ClickNoWait();

            IEInstance.WaitUntilContainsText("Setup/Upgrade Finished", 300);

            Assert.IsTrue(IEInstance.ContainsText("Setup/Upgrade Finished"));

            IEInstance.Button(Find.ById("InstallWizard_FinishNavigationTemplateContainerID_FinishButton")).ClickNoWait();

            IEInstance.WaitUntilContainsText("Welcome Guest!", 300);

            Assert.IsTrue(IEInstance.ContainsText("Welcome Guest!"), "Installation failed");
        }
예제 #16
0
        private static void StartIE()
        {
            int globalTimeout = 0;
            if (Int32.TryParse(ConfigurationManager.AppSettings["GlobalIETimeout"], out globalTimeout))
            {
                WatiN.Core.Settings.WaitForCompleteTimeOut = globalTimeout;
                defaultTimeout = globalTimeout;
            }

            _ie = new IE();
            //string baseUrl = String.Empty;
            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["BaseURL"]))
            {
                _ie.GoTo(ConfigurationManager.AppSettings["BaseURL"]);
            }
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["MaximizeBrowser"]))
            {
                _ie.ShowWindow(NativeMethods.WindowShowStyle.ShowMaximized);
            }

            InjectJQueryAjaxMonitor();
            // _ie.AddDialogHandler(new LogonDialogCloser());
            // _ie.AddDialogHandler(new MessageFromPageDialogHandler());
            //_ie.AddDialogHandler(new CloseIEDialogHandler(true));
        }
예제 #17
0
        public static void SDYD250()
        {
            IE ie = new IE("about:blank");
            ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
            using(StreamWriter writer = new StreamWriter("data.txt")) {
                writer.Write("Block:");
                writer.Write(",");
                writer.Write("Lot:");
                writer.Write(",");
                writer.Write("Prop Loc:");
                writer.Write(",");
                writer.Write("Land Desc:");
                writer.Write(",");
                writer.Write("Bldg Desc:");
                writer.Write(",");
                writer.Write("Taxes:");
                writer.Write(",");
                writer.Write("Sale Date:");
                writer.Write(",");
                writer.Write("Price:");
                writer.Write(",");
                writer.WriteLine("NU#:");
                for(int blockNum = 1; blockNum <= 106; blockNum++) {
                    ie.GoTo("http://tax1.co.monmouth.nj.us/cgi-bin/prc6.cgi?&ms_user=glou&passwd=data&district=0912");
                    SelectList listSize = ie.SelectList(Find.By("name", "ms_ln"));
                    listSize.Select("1000");
                    TextField block = ie.TextField(Find.By("name", "block"));
                    block.TypeText(blockNum.ToString());
                    ie.Forms[0].Submit();
                    List<string> links = new List<string>();
                    Button submit = null;
                    bool goNextPage = false;
                    do {
                        foreach(Link l in ie.Links) {
                            links.Add(l.Url);
                        }
                        try {
                            submit = ie.Button(Find.By("value", "Next"));
                            if(submit != null && submit.Text.ToLower() == "next") {
                                ie.Forms[0].Submit();
                                goNextPage = true;
                            }
                        } catch(ElementNotFoundException e) {}
                    } while(goNextPage);

                    foreach(string url in links) {
                        ie.GoTo(url);
                        writer.Write(GetData("Block:", ie.Tables));
                        writer.Write(",");
                        writer.Write(GetData("Lot:", ie.Tables));
                        writer.Write(",");
                        writer.Write(GetData("Prop Loc:", ie.Tables));
                        writer.Write(",");
                        writer.Write(GetData("Land Desc:", ie.Tables));
                        writer.Write(",");
                        writer.Write(GetData("Bldg Desc:", ie.Tables));
                        writer.Write(",");
                        writer.Write(GetData("Taxes:", ie.Tables));
                        writer.Write(",");
                        writer.Write(GetData("Sale Date:", ie.Tables));
                        writer.Write(",");
                        string priceData = GetData("Price:", ie.Tables);
                        string[] split = priceData.Split(new string[] {"NU#:"}, StringSplitOptions.RemoveEmptyEntries);
                        writer.Write(split[0]);
                        if(split.Length > 1) {
                            writer.Write(",");
                            writer.WriteLine(split[1]);
                        }
                        writer.WriteLine("");
                    }
                }

            }
            //ie.ShowWindow(NativeMethods.WindowShowStyle.Show);
            //ie.CaptureWebPageToFile("searchresult.htm");
            Console.WriteLine("Done!");
            Console.Read();
        }
예제 #18
0
 void Open()
 {
     try
     {
         ie = new IE();
         
         ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
         ie.ClearCache();
         ie.ClearCookies();
     }
     catch { }
     //ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
 }
예제 #19
0
        public void SetUp()
        {
            Settings.WaitForCompleteTimeOut = 80;
            Settings.WaitUntilExistsTimeOut = 80;

            platform = (Platform)Enum.Parse(typeof(Platform), System.Configuration.ConfigurationManager.AppSettings["Platform"]);
            //targetHost = System.Configuration.ConfigurationManager.AppSettings["TargetHost"];

            switch (platform)
            {
                case Platform.IE:
                    if (IE.InternetExplorers().Count == 0)
                    {
                        browser = new IE();
                        browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);

                    }
                    else
                    {
                        int pagecount = IE.InternetExplorers().Count;
                        int index=100;

                        for (int i=0; i < pagecount; i++)
                        {
                            if (IE.InternetExplorers()[i].Url.Contains(targetHost) == true)
                            {
                                index = i;
                            }

                        }
                        if (index != 100)
                        {
                            browser = IE.InternetExplorers()[index];
                        }
                        else
                        {
                            browser = new IE();
                        }
                        browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
                    }
                    break;
                    //if (IE.InternetExplorers().Count == 0)
                    //{
                    //    browser = new IE();
                    //}
                    //else
                    //{
                    //    int Count = IE.InternetExplorers().Count;

                    //    //for(int i; i<Count;i++)
                    //    //{
                    //    //    bool Contains;
                    //    //    Contains
                    //    //    IE.InternetExplorers()[1].Url.Contains(targetHost);

                    //    //}

                    //    if(IE.InternetExplorers())
                    //    {
                    //        browser = IE.InternetExplorers()[1];
                    //        IE.InternetExplorers()[1].Url.Contains(targetHost);
                    //    }
                    //    else
                    //    {
                    //        browser = new IE();
                    //    }
                    //}

                case Platform.FF:
                    browser = new FireFox();
                    browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
                    break;

            }
        }
예제 #20
0
        static void Main(string[] args)
        {
            IE  ie;

            string url = args[0];
            int scriptId = System.Int16.Parse(args[1]);

            switch (scriptId)
            {
                case 1:
                    {
                        ie = new IE(url);
                        ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
                        Thread.Sleep(3000);
                        ie.ForceClose();
                    }; break;
                case 2:
                    {
                        Settings.HighLightElement = true;
                        Settings.AutoMoveMousePointerToTopLeft = false;
                        Settings.MakeNewIe8InstanceNoMerge = true;
                        Settings.AttachToBrowserTimeOut = 60;
                        Settings.WaitForCompleteTimeOut = 60;
                        Settings.WaitUntilExistsTimeOut = 300;
                        Settings.AutoCloseDialogs = true;
                        ie = new IE(url, false);
                        ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
                        Thread.Sleep(3000);
                        ie.ForceClose();
                    }; break;
                case 3:
                    {
                        Settings.HighLightElement = true;
                        Settings.AutoMoveMousePointerToTopLeft = false;
                        Settings.MakeNewIe8InstanceNoMerge = true;
                        Settings.AttachToBrowserTimeOut = 60;
                        Settings.WaitForCompleteTimeOut = 60;
                        Settings.WaitUntilExistsTimeOut = 300;
                        Settings.AutoCloseDialogs = true;
                        ie = new IE(false);
                        ie.GoTo(url);
                        ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
                        Thread.Sleep(3000);
                        ie.ForceClose();
                    }; break;
                case 4:
                    {
                        Settings.HighLightElement = true;
                        Settings.AutoMoveMousePointerToTopLeft = false;
                        Settings.MakeNewIe8InstanceNoMerge = true;
                        Settings.AttachToBrowserTimeOut = 60;
                        Settings.WaitForCompleteTimeOut = 60;
                        Settings.WaitUntilExistsTimeOut = 300;
                        Settings.AutoCloseDialogs = true;
                        ie = new IE(true);
                        ie.GoTo(url);
                        ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
                        Thread.Sleep(3000);
                        ie.ForceClose();
                    }; break;
            }
            /*Settings.HighLightElement = true;
            Settings.AutoMoveMousePointerToTopLeft = false;
            Settings.MakeNewIe8InstanceNoMerge = true;
            //Settings.AttachToIETimeOut = 60;
            Settings.AutoCloseDialogs = true;
            Settings.WaitForCompleteTimeOut = 60;
            Settings.WaitUntilExistsTimeOut = 300;
            ie = new IE(true);
            ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
            ie.AutoClose = true;
            Thread.Sleep(3000);*/
        }
예제 #21
0
        private IEnumerable<string> GetVariantImages(Browser browser)
        {
            var variantImages = new List<string>();

            var links = browser.Div("colours_js_box").Divs.First().Links.Select(x => x.Title);
            foreach (var link in links)
            {
                Browser b = new IE(browser.Url);
                b.ShowWindow(NativeMethods.WindowShowStyle.Hide);
                b.Link(Find.ByTitle(link)).Click();
                var d = new HtmlDocument();
                d.LoadHtml(GetHtmlString(b.Url));
                b.Close();
                var node = d.DocumentNode.SelectNodes("//img[@id='productimage']").First();

                variantImages.Add(BaseAddress + node.Attributes["src"].Value);
            }
            return variantImages;
        }
예제 #22
0
        static string ScrapWebWatin()
        {
            Process[] processes = Process.GetProcessesByName("iexplore");

            foreach (Process process in processes)
            {
                process.Kill();
            }
            // Create an instance of Internet Explorer browser 
            using (IE ieInstance = new IE("http://sunnah.com/bukhari/1"))
            {
                // This will open Internet Explorer browser in maximized mode 
                ieInstance.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
                ieInstance.Visible = false;
                
                ieInstance.WaitForComplete();
                // This will store page source in categoryPageSource variable 

                var RdBtn = ieInstance.RadioButton(Find.ById("ch_indonesian"));
                if (RdBtn != null)
                {
                    RdBtn.Click();
                    // This will wait for the browser to complete loading of the page 

                    string HtmlPage = ieInstance.Html;
                    return HtmlPage;
                }
            }
            return string.Empty;
        }
        public virtual Browser CreateBrowser()
        {
            switch (browserConfiguration.BrowserType)
            {
                case BrowserType.IE:
                    var ie = new IE();
                    ie.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
                    return ie;

                case BrowserType.FireFox:
                    var fireFox = new FireFox();
                    return fireFox;

                case BrowserType.Chrome:
                    throw new NotSupportedException("Chrome browser not fully supported by WatiN at this time!");

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
예제 #24
0
        public void PopulateBrandMobilePhones(IEnumerable<int> brandIdList)
        {
            Settings.AttachToBrowserTimeOut = 240;
            Settings.WaitUntilExistsTimeOut = 240;
            Settings.WaitForCompleteTimeOut = 240;
            using (var dbContext = new MobilesDbContext())
            {
                try
                {
                    List<BrandPage> brandPages =
                        dbContext.BrandPages.Include("Brand").Where(p => brandIdList.Contains(p.Brand.Id) && p.IsRead == false).ToList();
                    foreach (BrandPage brandPage in brandPages)
                    {
                        string url = brandPage.Url;
                        try
                        {
                            using (var browser = new IE(url, true))
                            {
                                browser.ShowWindow(NativeMethods.WindowShowStyle.Hide);
                                browser.WaitForComplete();

                                IEnumerable<Div> productsDivs =
                                    browser.Divs.Where(d => d.ClassName != null && d.ClassName.Contains("makers"));

                                var listOfProducts = new List<OnlineShopModel.Product>();
                                foreach (Div productDiv in productsDivs)
                                {
                                    List productsList = productDiv.Lists.First();

                                    if (productsList != null && productsList.Exists)
                                    {
                                        foreach (ListItem productListItem in productsList.ListItems)
                                        {
                                            Link productLink = productListItem.Links.First();
                                            Element productName =
                                                productLink.Children().Where(c => c.TagName.ToUpper() == "STRONG").First();
                                            Image productImage = productLink.Images.First();
                                            listOfProducts.Add(new OnlineShopModel.Product
                                            {
                                                ProductName = productName.Text,
                                                Url = productLink.Url,
                                                ImageUrl = productImage.Src,
                                                Description = productImage.Title
                                            });
                                        }
                                    }
                                }

                                Database.SetInitializer(new CreateDatabaseIfNotExists<MobilesDbContext>());

                                List<Product> dbProductsList = dbContext.Products.ToList();

                                foreach (OnlineShopModel.Product product in listOfProducts)
                                {
                                    Product filterProduct = dbProductsList.Where(p => p.Url == product.Url).FirstOrDefault();
                                    if (filterProduct == null)
                                    {
                                        Product dbProduct = GetDbProduct(product);
                                        dbProduct.Brand = brandPage.Brand;
                                        dbContext.Products.Add(dbProduct);
                                    }
                                }

                                brandPage.IsRead = true;

                                dbContext.SaveChanges();
                            }
                        }
                        catch (Exception)
                        {

                        }

                    }
                }

                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadLine();
                    //throw ex;
                }
            }
        }
        public void Navigating()
        {
            using (var browser =
                new IE())
            {
                browser.AutoClose = false;
                browser.ShowWindow(NativeMethods.WindowShowStyle.Minimize);
                browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);

            browser.GoTo("http://www.bing.com");

            browser.GoTo("http://www.pluralsight.com");

            browser.Back();

            browser.Forward();
            }
        }
예제 #26
0
        public void PopulateBrandPages(IEnumerable<int> brandIdList)
        {
            Settings.AttachToBrowserTimeOut = 240;
            Settings.WaitUntilExistsTimeOut = 240;
            Settings.WaitForCompleteTimeOut = 240;
            using (var dbContext = new MobilesDbContext())
            {
                try
                {
                    List<string> brandPagesList = dbContext.BrandPages.Select(b => b.Url).Distinct().ToList();
                   List<DataModels.Brand> brands = dbContext.Brands.Where(b => brandIdList.Contains(b.Id)).ToList();
                  //  List<DataModels.Brand> brands = dbContext.Brands.ToList();
                    foreach (DataModels.Brand brand in brands)
                    {
                       // KillIeProcesses();
                        if (brandPagesList.Contains(brand.Url).Equals(false))
                        {
                            brand.BrandPages.Add(new BrandPage
                                                     {
                                                         Url = brand.Url,
                                                         IsInitialPage = true
                                                     });
                        }

                        string url = brand.Url;
                        using (var browser = new IE(url,true))
                        {
                            browser.ShowWindow(NativeMethods.WindowShowStyle.ForceMinimized);
                            browser.WaitForComplete();

                            Div mainDiv = browser.Div(Find.ById("main"));
                            if (mainDiv.Exists)
                            {
                                Div navigationDiv =
                                    mainDiv.Divs.Where(d => d.ClassName != null && d.ClassName.Contains("nav-pages")).
                                        FirstOrDefault();
                                if (navigationDiv != null && navigationDiv.Exists)
                                {
                                    List<string> pageLinks =
                                        navigationDiv.Links.Select(l=>l.Url).Distinct().ToList();

                                    foreach (var pageLink in pageLinks)
                                    {
                                        if (brandPagesList.Contains(pageLink).Equals(false))
                                        {
                                            brand.BrandPages.Add(new BrandPage
                                            {
                                                Url = pageLink
                                            });
                                        }
                                    }
                                }
                            }
                        }

                        dbContext.SaveChanges();
                    }

                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadLine();
                    //throw ex;
                }
            }
        }
예제 #27
0
        private IEnumerable<string> DeepHarvestShoeNode(HtmlNode node, ProductData product)
        {
            //Debugger.Launch();
            var productLink = BaseAddress + node.SelectNodes("p[@class='view_buy']/a").First().Attributes["href"].Value;

            var browser = new IE(productLink, false);
            browser.GoTo(productLink);
            browser.ShowWindow(NativeMethods.WindowShowStyle.Hide);

            var mainProductHtml = new HtmlDocument();
            var doc = HtmlNode.CreateNode("");
            IEnumerable<string> images = new string[0];
            try
            {
                mainProductHtml.LoadHtml(GetHtmlString(productLink));
                // //div[@id="productright"]/div[@class=product_info]/p
                doc = mainProductHtml.DocumentNode;

                images = GetVariantImages(browser);
                browser.Close();

                product.Handle = new Uri(productLink).AbsolutePath.Replace("/products/", string.Empty).Replace("/", "-");
                product.Body = "\"" + doc.SelectNodes("//div[@id='productright']/div[@class='product_info']/p").First().InnerText.Replace("\"", "'") + "\"";
                product.Type = "Mens Shoes"; DiscernType(product.Body, product.Title);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception thrown trying to parse: {0}", productLink);
            }

            HtmlNodeCollection colours = null;
            HtmlNodeCollection sizes = null;
            var productForm = doc.SelectNodes("//div[@id='product_form']").First();

            product.Option1Name = "Title";
            product.Option1Value = "Title";

            if (productForm.InnerHtml.Contains("Colour"))
            {
                colours = doc.SelectNodes("//div[@id='colours_js_box']").First().SelectNodes("//a[contains(@class,'product_colour')]");
                product.Option1Name = "Colour";
                product.Option1Value = colours.First().InnerText;
            }

            if (productForm.InnerHtml.Contains("Size"))
            {
                sizes = doc.SelectNodes("//div[@id='sizes_js_box']").First().SelectNodes("//a[contains(@class,'product_sizes')]");
                if (product.Option1Name == "Title")
                {
                    product.Option1Name = "Colour";
                    product.Option1Value = sizes.First().InnerText;
                }
                else
                {
                    product.Option2Name = "Size";
                    product.Option2Value = sizes.First().InnerText;
                }
            }

            product.Sku = productLink;
            product.Taxable = "FALSE";
            product.RequiresShipping = "TRUE";
            product.FulfillmentService = "manual";
            product.InventoryPolicy = "continue";
            product.Vendor = "Henry James";
            product.InventoryQuantity = "0";
            product.Tags = "Mens Shoes";
            product.Sizes = sizes;
            product.Colours = colours;

            return images;
        }
예제 #28
0
        static void GetSpecificContentWithWatin()
        {
            //Kill all ie
            Process[] processes = Process.GetProcessesByName("iexplore");

            foreach (Process process in processes)
            {
                process.Kill();
            }

            HadithDBEntities ctx = new HadithDBEntities();
            var hadist = (from c in ctx.Hadiths
                          where c.HadithID == 1 || c.HadithID == 3 || c.HadithID == 4
                          select c).ToList();
            using (IE ieInstance = new IE())
            {
                // This will open Internet Explorer browser in maximized mode 
                ieInstance.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
                ieInstance.Visible = false;

                ieInstance.WaitForComplete();
                // This will store page source in categoryPageSource variable 

                

                for (int i = 0; i < hadist.Count; i++)
                {
                    var selHadith = hadist[i];
                    var hadistIndex = (from c in ctx.HadithIndexes
                                       where c.HadithID == selHadith.HadithID
                                       && c.No != null
                                       orderby c.No
                                       select c).ToList();
                    for (int j = 0; j < hadistIndex.Count; j++)
                    {
                        var selIndex = hadistIndex[j];
                        var selURL = string.Format("http://sunnah.com/{0}/{1}", selHadith.Name, selIndex.No);

                        try
                        {
                            int HadithOrder = 0;
                            bool isIndonesian = false;
                            bool isUrdu = false;
                            ieInstance.GoTo(selURL);
                            var RdBtn = ieInstance.RadioButton(Find.ById("ch_indonesian"));
                            var RdBtn2 = ieInstance.RadioButton(Find.ById("ch_urdu"));

                            if (ieInstance.Elements.Exists("ch_indonesian") && RdBtn != null)
                            {
                                try
                                {
                                    RdBtn.Click();
                                    ieInstance.WaitForComplete();
                                    Thread.Sleep(500);
                                    // This will wait for the browser to complete loading of the page 
                                    isIndonesian = true;
                                }
                                catch { }
                            }
                            if (ieInstance.Elements.Exists("ch_urdu") && RdBtn2 != null)
                            {
                                try
                                {
                                    RdBtn2.Click();
                                    ieInstance.WaitForComplete();
                                    Thread.Sleep(500);

                                    // This will wait for the browser to complete loading of the page 
                                    isUrdu = true;
                                }
                                catch { }
                            }
                            string HtmlPage = ieInstance.Html;
                            HtmlDocument doc = new HtmlDocument();
                            doc.LoadHtml(HtmlPage);
                            HadithChapter selChapter = null;
                            int ContentCounter = 0;

                            HadithPage selPage = new HadithPage();
                            selPage.PageNo = selIndex.No;
                            selPage.HadithID = selHadith.HadithID;
                            //get title
                            foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//div"))
                            {
                                if (node.Attributes["class"] != null && !string.IsNullOrEmpty(node.Attributes["class"].Value))
                                {
                                    switch (node.Attributes["class"].Value)
                                    {
                                        case "book_page_english_name":
                                            selPage.Title = node.InnerText.Trim();
                                            break;
                                        case "book_page_arabic_name arabic":
                                            selPage.TitleArabic = node.InnerText.Trim();
                                            //ctx.HadithPages.Add(selPage);
                                            break;
                                        case "chapter":
                                            selChapter = new HadithChapter();
                                            selChapter.HadithID = selHadith.HadithID;
                                            selChapter.PageNo = selPage.PageNo;
                                            //iterate every chapter
                                            var chapterNode = node;
                                            {
                                                var subnode = chapterNode.SelectSingleNode(".//div[@class='echapno']");
                                                if (subnode != null)
                                                {
                                                    try
                                                    {
                                                        selChapter.ChapterNo = Convert.ToInt32(subnode.InnerText.Trim().Replace("(", "").Replace(")", ""));
                                                    }
                                                    catch
                                                    {
                                                        var Parsed = subnode.InnerText.Trim().Replace("(", "").Replace(")", "");
                                                        if (Parsed.Contains(','))
                                                        {
                                                            selChapter.ChapterNo = Convert.ToInt32(Parsed.Split(',')[0]);
                                                        }
                                                        else
                                                        {
                                                            for (int z = 0; z < Parsed.Length; z++)
                                                            {
                                                                if (!(Parsed[z] >= '0' && Parsed[z] <= '9'))
                                                                {
                                                                    Parsed = Parsed.Replace(Parsed[z].ToString(), " ");
                                                                }
                                                            }
                                                            selChapter.ChapterNo = Convert.ToInt32(Parsed.Trim());
                                                        }
                                                    }
                                                }
                                            }
                                            {
                                                var subnode = chapterNode.SelectSingleNode(".//div[@class='englishchapter']");
                                                if (subnode != null)
                                                {
                                                    selChapter.Title = subnode.InnerText.Trim();
                                                }
                                            }
                                            {
                                                var subnode = chapterNode.SelectSingleNode(".//div[@class='arabicchapter arabic']");
                                                if (subnode != null)
                                                {
                                                    selChapter.TitleArabic = subnode.InnerText.Trim();
                                                }
                                            }
                                            //ctx.HadithChapters.Add(selChapter);
                                            break;
                                        case "arabic achapintro":
                                            {
                                                if (selChapter != null)
                                                {
                                                    selChapter.Intro = node.InnerText.Trim();
                                                }
                                            }
                                            break;
                                        case "actualHadithContainer":
                                            HadithContent selContent = new HadithContent();
                                            selContent.HadithID = selHadith.HadithID;
                                            selContent.PageNo = selPage.PageNo;
                                            selContent.HadithOrder = ++HadithOrder;
                                            if (selChapter != null)
                                            {
                                                selContent.ChapterNo = selChapter.ChapterNo;
                                            }
                                            {
                                                var subnode = node.SelectSingleNode(".//div[@class='hadith_narrated']");
                                                if (subnode != null)
                                                {
                                                    selContent.Narated = subnode.InnerText.Trim();
                                                }
                                            }
                                            {
                                                var subnode = node.SelectSingleNode(".//div[@class='text_details']");
                                                if (subnode != null)
                                                {
                                                    selContent.ContentEnglish = subnode.InnerText.Trim();
                                                }
                                            }
                                            if(isIndonesian)
                                            {
                                                var subnode = node.SelectSingleNode(".//div[@class='indonesian_hadith_full']");
                                                if (subnode != null)
                                                {
                                                    selContent.ContentIndonesia = subnode.InnerText.Trim();
                                                }
                                            }
                                            if (isUrdu)
                                            {
                                                var subnode = node.SelectSingleNode(".//div[@class='urdu_hadith_full']");
                                                if (subnode != null)
                                                {
                                                    selContent.ContentUrdu = subnode.InnerText.Trim();
                                                }
                                            }
                                            {
                                                var subnode = node.SelectSingleNode(".//table[@class='gradetable']");
                                                if (subnode != null)
                                                {
                                                    selContent.Grade = subnode.InnerText.Trim();
                                                }
                                            }
                                            {
                                                var subnode = node.SelectSingleNode(".//table[@class='hadith_reference']");
                                                if (subnode != null)
                                                {
                                                    selContent.Reference = subnode.InnerText.Trim();
                                                }
                                            }
                                            {
                                                var subnode = node.SelectNodes(".//span[@class='arabic_sanad arabic']");
                                                if (subnode != null)
                                                {
                                                    selContent.SanadTop = subnode[0].InnerText.Trim();
                                                    selContent.SanadBottom = subnode[1].InnerText.Trim();
                                                }

                                            }
                                            {
                                                var subnode = node.SelectSingleNode(".//span[@class='arabic_text_details arabic']");
                                                if (subnode != null)
                                                {
                                                    selContent.ContentArabic = subnode.InnerText.Trim();
                                                }
                                            }
                                            ctx.HadithContents.Add(selContent);
                                            ContentCounter++;
                                            if (ContentCounter > 100)
                                            {
                                                ctx.SaveChanges();
                                                ContentCounter = 0;
                                            }
                                            break;
                                        default: break;
                                    }
                                }


                            }

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(selURL + ":" + ex.Message + "-" + ex.StackTrace);
                        }

                        ctx.SaveChanges();
                    }
                }
            }
            Console.WriteLine("selesai");
            Console.ReadLine();
        }
예제 #29
0
        public Result LaunchPageInBrowser(string Url)
        {
            try
            {
                browser = new IE(Url);

                browser.WaitForComplete();
            }
            catch (Exception e)
            {
                Console.WriteLine("BaseFixture.LaunchPageInBrowser: " + e.ToString());

                Thread.Sleep(500);

                browser = new IE(Url);

                browser.WaitForComplete();
            }

            browser.BringToFront();

            browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);

            return Result.CreatePass();
        }