Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        public Result ForceBrowserClose(bool forceClose)
        {
            if (isLocal || forceClose)
            {
                try
                {
                    browser = new IE(Urls.Root);

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

                    Thread.Sleep(500);

                    browser = new IE(Urls.Root);

                    browser.WaitForComplete();
                }

                CloseBrowser(forceClose);
            }

            return Result.CreatePass();
        }
Ejemplo n.º 3
0
 private void frmWebBowser_Load(object sender, EventArgs e)
 {
     webBrowser1.ScriptErrorsSuppressed = true;
     //IE.Settings.AutoStartDialogWatcher = false;
     WatiN.Core.Settings.AutoStartDialogWatcher = false;
     ie = new IE(webBrowser1.ActiveXInstance);
 }
 public void HomePageContainsFreshOffTheGrillAlbumList()
 {
     using (var browser = new IE("http://localhost:1200/"))
     {
         Assert.IsTrue(browser.List(Find.ById("album-list")).Children().Any());
     }
 }
Ejemplo n.º 5
0
        private void frmWebBowser_Load(object sender, EventArgs e)
        {
            Settings.WaitForCompleteTimeOut = 120000;
            Settings.AttachToBrowserTimeOut = 120000;
           
            webBrowser1.ScriptErrorsSuppressed = false;

            Settings.AutoStartDialogWatcher = false;
            ie = new IE(webBrowser1.ActiveXInstance);
            try
            {
                ie.ClearCache();
            }
            catch
            {
            }
            //ie = new IE();
            dialogWatcher = new DialogWatcher(new Window(this.Handle));
            dialogWatcher.CloseUnhandledDialogs = false;
            webpage = new WebPage();
            lookUpEditPage.Properties.DataSource = WebPage.GetAll();
            lookUpEditPage.Properties.DisplayMember = "Page";
            lookUpEditPage.Properties.ValueMember = "ID";
            if (pageID > 0)
            {
                lookUpEditPage.EditValue = long.Parse(pageID.ToString());
            }
        }
        public void LocatingThings()
        {
            using (var browser =
                new IE("http://www.pluralsight.com"))
            {
                //// Get a reference to a HTML input element, type=text, id=Name
                //TextField applicantName = browser.TextField(Find.ById("Name"));

                //// Get a reference to a HTML link element with id=HelpLink
                //Link helpHyperlink = browser.Link(Find.ById("HelpLink"));

                //// Get a reference to a HTML input element, type=submit, id=ApplyNow
                //Button applyButton = browser.Button(Find.ById("ApplyNow"));

                //// Get a reference to a HTML paragraph element, id=Name
                //Para nameParagraph = browser.Para(Find.ById("Name"));

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

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

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

            Para nameParagraph = browser.Para(Find.ById("Name"));
            }
        }
Ejemplo n.º 7
0
        public void TestAlterDescription()
        {
            WatiN.Core.IE window = ie;
            ie.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx");
            base.Login(ie);
            Button btn_ctl00ContentPlac = window.Button(Find.ByName("ctl00$ContentPlaceHolder1$PhotoAlbumManager1$grdPhotoAlbum$ctl04$Button1"));

            Assert.That(btn_ctl00ContentPlac.Exists);
            Span spn_ctl00_ContentPla = window.Span(Find.ById("ctl00_ContentPlaceHolder1_PhotoAlbumManager1_frmEdit_rptPhoto_ctl00_SinglePhotoThumbnail1_lblDescription"));

            Assert.That(spn_ctl00_ContentPla.Exists);
            //Added after the registration
            TextField txt_editCurrent = window.TextField(Find.ById("editCurrent"));

            Assert.That(txt_editCurrent.Exists);
            txt_editCurrent.WaitUntilExists(3000);

            window.GoTo("http://localhost:13164/Photo/PhotoAlbumManager.aspx");

            btn_ctl00ContentPlac.Click();

            spn_ctl00_ContentPla.Click();

            txt_editCurrent.Click();


            txt_editCurrent.AppendText("!!");
            txt_editCurrent.KeyDown('\n');
        }
 public void HomePageContainsPromotionPanel()
 {
     using (var browser = new IE("http://localhost:1200/"))
     {
         Assert.IsTrue(browser.Div(Find.ById("promotion")).Exists);
     }
 }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
        public void home_page_should_have_vidpub_name() {

            using (var browser = new IE("http://localhost:1701")) {
                Assert.True(browser.Title.Contains("VidPub"));
            }

        }
Ejemplo n.º 11
0
        public void Solve(string url)
        {
            _browser = new IE(url);
            _puzzle = ParsePuzzle();

            var solver = new Solver();

            //solver.Reduced += SolverOnReduced;

            solver.Solve(_puzzle);

            SolverOnReduced(null, null);

            if (_puzzle.IsSolved)
            {
                return;
            }

            if (File.Exists("e:\\out.html"))
            {
                File.Delete("e:\\out.html");
            }

            File.WriteAllText("e:\\out.html", GetPuzzleHtml());
        }
Ejemplo n.º 12
0
        public void Solve(string url)
        {
            _browser = new IE(url);
            _puzzle = ParsePuzzle();

            var solver = new GuessingSolver();

            // solver.Reduced += SolverOnReduced;

            solver.Solve(_puzzle);

            SolverOnReduced(null, null);

            if (_puzzle.IsSolved)
            {
                return;
            }

            if(_puzzle.HasErrors)
            {
                System.Console.WriteLine("Puzzle has Errors");
            }
            var tempPath = Path.GetTempPath();

            string tempFileName;
            do
            {
                tempFileName = Path.Combine(tempPath, Guid.NewGuid().ToString().Remove(8) + ".html");
            } while (File.Exists(tempFileName));

            File.WriteAllText(tempFileName, GetPuzzleHtml());
            Process.Start(tempFileName);
        }
Ejemplo n.º 13
0
    public void SetUp()

    {
      //System.Threading.Thread.CurrentThread.ApartmentState = System.Threading.ApartmentState.STA;
      ie = new IE();

    }
Ejemplo n.º 14
0
 public static HtmlNode GettingHtml(IE browser)
 {
     var doc = new HtmlDocument(); //install parsed doc in HTML Agility Pack
     doc.LoadHtml(browser.Body.OuterHtml); //place html in parser from Bank.Gov
     var dataBlock = doc.DocumentNode.SelectSingleNode("//div[@class=\"content\"]");
     return dataBlock;
 }
Ejemplo n.º 15
0
 public static string Goto(String text, IE ie)
 {
     int i = 0;
     while (i < Loop)
     {
         i++;
         try
         {
             ie.GoTo(text);
             ie.WaitForComplete();
             //ie.WaitUntilContainsText("message");
             return string.Empty;
         }
         catch (Exception ex)
         {
             if (i == Loop)
             {
                 return ex.Message;
             }
             ie.Close();
             Thread.Sleep(60000);
             ie.Reopen();
         }
     }
     return string.Empty;
 }
        public void TestFixtureSetUp()
        {
            browser = new IE(BuildUrl("Login", "Index"));
            CompleteLoginForm(browser, "johnpolling", "password");

            listPluginUrl = BuildUrl("Administrator", "Plugins", "List");
        }
Ejemplo n.º 17
0
        public void Teardown()
        {
            if (_browser != null)
            {
                try
                {
                    _browser.Close();
                    _browser.Dispose();
                }
                catch (Exception)
                {
                }
            }

            try
            {
                var ieProcessList = Process.GetProcessesByName("iexplore");
                foreach (var process in ieProcessList)
                {
                    process.Kill();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }

            _browser = null;
        }
Ejemplo n.º 18
0
 public ActionBase(awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
 {
     this.DAL    = dal;
     this.IE     = ie;
     Repetitions = 1;
     this.Target = target;
 }
Ejemplo n.º 19
0
 public static AttributeConstraint GetControl(IE ie, HControl control)
 {
     //Regex regex = new Regex(FilterPattern.GetToPattern(control.Value));
     String regex = control.Value;
     switch (control.Attribute.ToLower())
     {
         case AttributeType.Id:
             return Find.ById(regex);
         case AttributeType.Name:
             return Find.ByName(regex);
         case AttributeType.Class:
             return Find.ByClass(regex);
         case AttributeType.Text:
             {
                 Regex regexs = new Regex(FilterPattern.GetToPattern(control.Value));
                 return Find.ByText(regexs);
             }
         case AttributeType.Value:
             {
                 Regex regexs = new Regex(FilterPattern.GetToPattern(control.Value));
                 return Find.ByValue(regexs);
             }
         default:
             return Find.ByName(regex);
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Closes the given IE instance.
 /// </summary>
 /// <param name="ieInstance">The IE instance to be closed.</param>
 public static void CloseIEInstance(IE ieInstance)
 {
     if (ieInstance != null)
     {
         ieInstance.Close();
     }
 }
Ejemplo n.º 21
0
 public void GivenIHaveAValidLoginAndPassword()
 {
     using(var browser = new IE("http://localhost:58577/"))
     {
     }
     //ScenarioContext.Current.Pending();
 }
Ejemplo n.º 22
0
        private static void Chat(WebClient client, string path)
        {
            using (File.Create(path))
            {
            }

            using (var browser = new IE("http://widget.chatvdvoem.ru/iframe?mode=production&height=600"))
            {
                browser.Link(Find.ById("chat_start")).Click();

                var lastAnswer = string.Empty;
                var answer = string.Empty;

                while (true)
                {
                    var i = 0;

                    while (string.Equals(lastAnswer, answer,
                        StringComparison.InvariantCultureIgnoreCase))
                    {
                        Thread.Sleep(7000);

                        i++;

                        if (i > 4)
                        {
                            browser.ForceClose();
                            return;
                        }

                        var froms = browser.Elements.Filter(p => p.ClassName == "messageFrom");

                        if (froms.Count == 0)
                            continue;

                        answer = froms.Last().Text;

                        answer = answer.Substring(6);
                    }

                    lastAnswer = answer;

                    if (BlackListed(answer))
                        break;

                    var question = GetAnswer(client, answer);

                    File.AppendAllLines(path, new[] { answer, question });

                    browser.TextField(Find.ByName("text")).TypeText(question);

                    Thread.Sleep(2000);

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

                browser.ForceClose();
            }
        }
 public void Cannot_find_first_name_by_rel_text_regex_when_there_is_no_match()
 {
     using (var browser = new IE(url))
     {
         var page = browser.Page<HomeIndexPage>();
         Assert.IsFalse(page.FirstNameNotFoundByLabelTextRegex.Exists);
     }
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Closes the given IE instance.
 /// </summary>
 /// <param name="ieInstance">The IE instance to be closed.</param>
 public static void CloseIEInstance(IE ieInstance)
 {
     if (ieInstance != null)
     {
         ieInstance.ForceClose();
         Thread.Sleep(2000);
     }
 }
Ejemplo n.º 25
0
 public void Verify_WebsiteUp()
 {
     using (var browser = new IE("http://localhost/Sample.Web_deploy"))
     {
         var hasText = browser.ContainsText("Getting started");
         Assert.IsTrue(hasText);
     }
 }
Ejemplo n.º 26
0
        public virtual void SetUp()
        {
            IE.Settings.AutoMoveMousePointerToTopLeft = false;

            _webServer = new DevWebServer();
            _webServer.Start();
            _ie = new IE(_webServer.BaseUrl, true);
        }
 public void Can_find_first_name_by_rel_text_regex()
 {
     using (var browser = new IE(url))
     {
         var page = browser.Page<HomeIndexPage>();
         Assert.IsTrue(page.FirstNameByLabelTextRegex.Exists);
     }
 }
Ejemplo n.º 28
0
        public PageInteraction(IE browser)
        {
            _browser = browser;
            _pageUrls = new PageUrls();

            ScenarioContext.Current["username"] = username;
            ScenarioContext.Current["password"] = password;
        }
Ejemplo n.º 29
0
 public virtual void TearDown()
 {
     if (browser != null)
     {
         browser.Dispose();
         browser = null;
     }
 }
 public void Cannot_find_unidentified_child_text_field_by_ancestor_regex()
 {
     using (var browser = new IE(url))
     {
         var page = browser.Page<HomeIndexPage>();
         Assert.IsFalse(page.UnidentifiedChildTextFieldByRegexNotFound.Exists);
     }
 }
Ejemplo n.º 31
0
 public void WebPageToImageTest()
 {
     //Capture(null, null);
     using (var ie = new IE("http://watin.org/"))
     {
         ie.CaptureWebPageToFile(@"c:\temp\g1.jpg");
     }
 }
Ejemplo n.º 32
0
        public void NavigateTo(string url)
        {
            if (_browser == null)
            {
                _browser = new IE();
            }

            _browser.GoTo(url);
        }
Ejemplo n.º 33
0
        public void NavigateTo(string url)
        {
            Debug.WriteLine("Navigating browser to " + url);

            if (_browser == null)
            {
                _browser = new IE();
            }

            _browser.GoTo(url);
        }
Ejemplo n.º 34
0
        public static void safeWaitUntilComplete(IE ie, int msTimeout)
        {
            int msSlept = 0;

            while (WatiN.Core.WatiNExtensions.isBusy(ie) && msSlept < msTimeout)
            {
                System.Threading.Thread.Sleep(100);
                msSlept += 100;
            }
            if (msSlept >= msTimeout)
            {
                throw new System.ApplicationException("method safeWaitUntilComplete timed out");
            }
        }
Ejemplo n.º 35
0
        private WC.IE OpenVehicleInfoWindow(WC.TableCellCollection tdsInput)
        {
            Func <WC.TableCellCollection, WC.IE> f = (tds) => {
                var link   = tds[2].Links.First();
                var target = link.GetAttributeValue("target");
                link.SetAttributeValue("target", _vehicleInfoTargetName);
                link.Click();
                try {
                    vehicleInfoIE = WC.IE.AttachTo <WC.IE>(WC.Find.ByTitle(t => {
                        return(t.StartsWith("Manheim - PowerSearch"));
                    }));
                } catch { }
                if (vehicleInfoIE == null || vehicleInfoIE.Title == "Manheim - PowerSearch - Search Results")
                {
                    try {
                        vehicleInfoIE = WC.IE.AttachTo <WC.IE>(WC.Find.ByTitle(t => {
                            return(t == "Manheim - PowerSearch - Search Results");
                        }));
                        if (vehicleInfoIE != null)
                        {
                            var vehicle_detail_row = vehicleInfoIE.TableRow(WC.Find.ByClass("vehicle_detail_row "));
                            if (vehicle_detail_row.Exists)
                            {
                                var link1 = vehicle_detail_row.Link("vehicleDetailsLink_0");
                                if (link1 != null)
                                {
                                    link1.Click();
                                    try {
                                        return(WC.IE.AttachTo <WC.IE>(WC.Find.ByTitle(t => {
                                            return t == "Manheim - PowerSearch - Vehicle Details";
                                        })));
                                    } catch { }
                                }
                            }
                            Log = new Exception("VehicleInfo window not found.");
                        }
                    } catch { }
                }
                return(vehicleInfoIE);
            };

            if (Application.Current.Dispatcher.CheckAccess())
            {
                return(f(tdsInput));
            }
            var d = Application.Current.Dispatcher.BeginInvoke(f, tdsInput);

            d.Wait(TimeSpan.FromSeconds(30));
            return(d.Result as WC.IE);
        }
Ejemplo n.º 36
0
Archivo: IE.cs Proyecto: minskowl/MY
        private static IE FindIEPartiallyInitialized(Constraint findBy)
        {
            var allBrowsers = new ShellWindows2();

            var context = new ConstraintContext();

            foreach (IWebBrowser2 browser in allBrowsers)
            {
                var ie = new IE(browser, false);
                if (ie.Matches(findBy, context))
                {
                    return(ie);
                }
            }

            return(null);
        }
Ejemplo n.º 37
0
        public void TestWebUIButtonValidation()
        {
            var input = 0;

            string[] Headers = { "All Numbers:",
                                 "All Odd Numbers:",
                                 "All Even Numbers:",
                                 "All Extended FizzBuzzs:",
                                 "All Fibonacci Numbers:" };

            using (var browser = new WatiN.Core.IE(testUrl))
            {
                browser.TextField(Find.ByName("txtNumber")).TypeText(input.ToString());
                browser.Button(Find.ByName("btnGenerate")).Click();
                browser.WaitForComplete();

                Assert.IsTrue(string.IsNullOrWhiteSpace(browser.Divs[0].Text));
            }
        }
Ejemplo n.º 38
0
        public IECollection(bool waitForComplete)
        {
            _waitForComplete = waitForComplete;

            internetExplorers = new ArrayList();

            ShellWindows allBrowsers = new ShellWindows();

            foreach (SHDocVw.InternetExplorer internetExplorer in allBrowsers)
            {
                try
                {
                    if (internetExplorer.Document is IHTMLDocument2)
                    {
                        IE ie = new IE(internetExplorer);
                        internetExplorers.Add(ie);
                    }
                }
                catch {}
            }
        }
        private static WatiN.Core.IE CreateIEBrowser()
        {
            Process ieProcess = CreateIExploreInNewProcess();

            IeWindowFinder findWindow = new IeWindowFinder(ieProcess);

            var action = new WatiN.Core.UtilityClasses.TryFuncUntilTimeOut(TimeSpan.FromSeconds(WatiN.Core.Settings.AttachToBrowserTimeOut))
            {
                SleepTime = TimeSpan.FromMilliseconds(500)
            };

            IntPtr hWnd = action.Try(() =>
            {
                return(findWindow.Find());
            });

            ieProcess.Refresh();

            WatiN.Core.IE ie = WatiN.Core.IE.AttachTo <WatiN.Core.IE>(
                new WatiN.Core.Constraints.AttributeConstraint("hwnd", hWnd.ToString()), 5);

            return(ie);
        }
        public static WatiN.Core.IE GetBrowser()
        {
            Settings.AttachToBrowserTimeOut = 240;

            Settings.WaitUntilExistsTimeOut = 240;
            Settings.WaitForCompleteTimeOut = 240;
            WatiN.Core.IE browser = null;


            VerifyDisponibility();
            try
            {//Primeira tentativa de criar o browser
                browser = CreateIEBrowser();
            }
            catch
            {//Caso dê algum problema tenta criar o browser mais uma vez
                System.Threading.Thread.Sleep(new TimeSpan(0, 0, 5));
                VerifyDisponibility();
                browser = CreateIEBrowser();
            }

            return(browser);
        }
Ejemplo n.º 41
0
        public static void GetNewAccount(out string Account, out string Password)
        {
            // Windows
            WatiN.Core.IE window = new WatiN.Core.IE("http://www.forexmicrolot.com/open-free-micro-uk.jsp");

            // Frames

            // Model
            var        frame       = ((WatiN.Core.Document)(window)).Frames[0];
            TextField  txt_FNAME   = frame.TextField(Find.ByName("FNAME"));
            TextField  txt_LNAME   = frame.TextField(Find.ByName("LNAME"));
            TableCell  td_         = frame.TableCell(Find.ByText(""));
            SelectList sel_COUNTRY = frame.SelectList(Find.ByName("COUNTRY"));
            TextField  txt_EMAIL   = frame.TextField(Find.ByName("EMAIL"));
            Image      img_submit  = frame.Image(Find.ByName("submit"));

            // Code
            txt_FNAME.Click();
            txt_FNAME.TypeText("a");
            txt_LNAME.Click();
            txt_LNAME.TypeText("a");
            td_.Click();
            sel_COUNTRY.SelectByValue("Afghanistan");
            txt_EMAIL.Click();
            txt_EMAIL.TypeText("*****@*****.**");
            td_.Click();
            img_submit.Click();
            window.WaitForComplete();
            frame = ((WatiN.Core.Document)(window)).Frames[0];
            var TD = frame.TableCell(td => td.Text == "User ID");

            Account  = TD.ContainingTableRow.OwnTableCells[2].Text;
            TD       = frame.TableCell(td => td.Text == "Password");
            Password = TD.ContainingTableRow.OwnTableCells[2].Text;
            window.Dispose();
        }
Ejemplo n.º 42
0
 public SelectAction(string item, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.item = item;
 }
Ejemplo n.º 43
0
 /// <summary>
 /// This Class Represent a typing in a text input field action
 /// </summary>
 /// <param name="text">the text to fill in the field</param>
 /// <param name="dal">the DAL class instance</param>
 /// <param name="ie">the WatiN browser object</param>
 /// <param name="target">the Target Object upon which to act</param>
 public TypeAction(string text, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.text = text;
 }
Ejemplo n.º 44
0
 public UnCheckAction(awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
 }
Ejemplo n.º 45
0
        private void GetAllVehiclesForTheDay(string state, string auctionName, string listAllLink)
        {
            var there = false;

            while (!there)
            {
                try {
                    Browser.GoTo(listAllLink.Replace("standard", "enhanced"));
                    there = true;
                } catch (WC.Exceptions.TimeoutException) { }
            }
            var dataTable = Browser.ElementOfType <WC.Table>(WC.Find.ByClass("dataTable"));

            if (!dataTable.Exists)
            {
                return;
            }
            var dataHeader = dataTable.ChildWithTag("thead", WC.Find.Any).AsElementContainer();
            var trHeader   = dataHeader.ElementsOfType <WC.TableRow>().First();

            foreach (var cell in trHeader.ChildrenWithTag("th"))
            {
                Debug.WriteLine(Regex.Replace(cell.Text, @"[\W]", ""));
            }
            var dataBody     = dataTable.TableBody(WC.Find.Any);
            var manheimModel = new Manheim.Model.ManheimEntities(dbPath);

            var stateEntity = manheimModel.States.Where(s => s.Name == state).SingleOrDefault();

            if (stateEntity == null)
            {
                Log = new Exception("State " + state + " is not found.");
                return;
            }

            var mainColumn = Browser.Divs.Filter(WC.Find.ById("mainColumn")).Single();

            #region Get Manager
            Model.Manager managerEntity = null;
            var           para          = mainColumn.Para(p => p.Children().Select(c => c.TagName).DefaultIfEmpty("").First() == "B");
            if (para != null)
            {
                var b           = para.Children().First();
                var managerName = b.Exists && b.TextAfter.Contains("-") ? b.Text.Trim() : "";
                managerEntity = manheimModel.Managers.SingleOrDefault(m => m.Name == managerName);
                if (managerEntity == null && !string.IsNullOrEmpty(managerName))
                {
                    var managerTitle = b.Exists ? b.TextAfter.Split('-')[1].Trim() : "";
                    b = b.Exists ? b.NextSibling : b;
                    var phoneFaxMail = b.Exists ? b.TextAfter.Split(';') : new string[0];
                    var phone        = phoneFaxMail.Length > 0 ? phoneFaxMail[0].Split(':')[1].Trim() : "";
                    var fax          = phoneFaxMail.Length > 1 ? phoneFaxMail[1].Split(':')[1].Trim() : "";
                    var email        = b.Exists ? b.NextSibling.Text.Trim() : "";
                    managerEntity = new Model.Manager()
                    {
                        Name  = managerName,
                        Title = managerTitle,
                        Phone = phone,
                        Fax   = fax,
                        Email = email
                    };
                    manheimModel.Managers.Add(managerEntity);
                    manheimModel.SaveChanges();
                }
            }
            else
            {
                managerEntity = manheimModel.Managers.SingleOrDefault(m => m.Name == "");
                if (managerEntity == null)
                {
                    managerEntity = new Model.Manager()
                    {
                        Email = "", Fax = "", Phone = "", Title = "", Name = ""
                    };
                    manheimModel.Managers.Add(managerEntity);
                    manheimModel.SaveChanges();
                }
            }
            #endregion

            #region Get Auction
            var auctionEntity = manheimModel.Auctions.SingleOrDefault(a => a.Name == auctionName);
            if (auctionEntity == null)
            {
                auctionEntity = new Model.Auction()
                {
                    Name           = auctionName,
                    State          = stateEntity,
                    PreSaleManager = managerEntity
                };
                manheimModel.Auctions.Add(auctionEntity);
                manheimModel.SaveChanges();
            }
            #endregion

            var      saleDateText = mainColumn.ElementWithTag("h4", WC.Find.ByText(new Regex(@"\d{2}/\d{2}/\d{4}"))).Text.Split('-')[0].Trim();
            DateTime saleDate;

            if (!DateTime.TryParse(saleDateText, out saleDate))
            {
                Log = new Exception("Sale date not found for " + auctionName + " in " + state);
                return;
            }

            #region if(false)Delete by SaleDate
            var md   = ((IObjectContextAdapter)manheimModel).ObjectContext.MetadataWorkspace;
            var item = md.GetItems(DataSpace.CSpace);
            item = md.GetItems(DataSpace.CSSpace);
            item = md.GetItems(DataSpace.OCSpace);
            item = md.GetItems(DataSpace.OSpace);
            item = md.GetItems(DataSpace.SSpace);
            if (false)
            {
                var preSaleTable   = typeof(Model.PreSale).GetCustomAttributes(typeof(EdmEntityTypeAttribute), true).Cast <EdmEntityTypeAttribute>().First();
                var auctionIdField = ExpressionExtentions.GetLambda(() => new Model.PreSale().AuctionId);
                manheimModel.Database.ExecuteSqlCommand("DELETE " + preSaleTable.Name + " WHERE " + auctionIdField + " = {0}", auctionEntity.AuctionId);
            }
            #endregion

            //dataBody.OwnTableRows.ToList().ForEach(tr =>
            foreach (var tr in dataBody.OwnTableRows)
            {
                var tds = tr.OwnTableCells;
                if (tds.Count == 0)
                {
                    continue;
                }
                var vin         = tds[6].Text + "";
                var addPresSale = false;
                lock (auctionEntity) {
                    addPresSale = !manheimModel.PreSales.Any(ps => ps.SaleDate == saleDate && ps.VIN == vin);
                }

                if (addPresSale)
                {
                    try {
                        WC.IE vehicleInfoIE = OpenVehicleInfoWindow(tds);
                        if (vehicleInfoIE != null)
                        {
                            AddPreSale(manheimModel, auctionEntity, saleDate, tds, vin, vehicleInfoIE);
                        }
                    } catch (System.Data.Entity.Validation.DbEntityValidationException exc) {
                        var ev = exc.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage;
                        Log = new Exception(ev);
                    }
                }
            }
        }
Ejemplo n.º 46
0
        private static void AddPreSale(Model.ManheimEntities manheimModel, Model.Auction auctionEntity, DateTime saleDate, WC.TableCellCollection tds, string vin, WC.IE vehicleInfoIE)
        {
            var rightContent = vehicleInfoIE.Div("rightContent");

            #region Vehicle

            #region Grade
            var grade      = 0.0;
            var lastColumn = rightContent.Div(WC.Find.ByClass("lastColumn"));
            if (lastColumn.Exists)
            {
                var gradeLink = lastColumn.Link(WC.Find.ByText(new Regex("Grade")));
                if (gradeLink.Exists)
                {
                    double.TryParse(Regex.Replace(gradeLink.Text, @"[^\d.]", ""), out grade);
                }
            }
            #endregion


            var mmrElement = vehicleInfoIE.Link("mmrHover");
            int mmrPrice   = 0;
            if (mmrElement.Exists)
            {
                int.TryParse(mmrElement.Text, NumberStyles.AllowThousands | NumberStyles.AllowCurrencySymbol, NumberFormatInfo.CurrentInfo, out mmrPrice);
            }
            var div   = vehicleInfoIE.Div(new Regex("vdpTab_detail-1"));
            var table = div.Tables.First();
            if (table != null)
            {
                var vehicleEntity = manheimModel.Vehicles.SingleOrDefault(v => v.VIN == vin);
                if (vehicleEntity == null)
                {
                    vehicleEntity       = SetVehicle(table);
                    vehicleEntity.Grade = grade;
                    manheimModel.Vehicles.Add(vehicleEntity);
                }
                else
                {
                    UpdateVehicle(vehicleEntity, table);
                }
                vehicleEntity.MMR = mmrPrice;
                manheimModel.SaveChanges();
                #endregion

                #region Seller
                var sellerElement = rightContent.Div(WC.Find.ByClass("firstColumn")).ElementWithTag("li", WC.Find.First());
                var sellerName    = sellerElement.Exists ? sellerElement.Text : "";
                var sellerEntity  = manheimModel.Sellers.SingleOrDefault(s => s.Name == sellerName);
                if (sellerEntity == null)
                {
                    sellerEntity = new Model.Seller()
                    {
                        Name = sellerName
                    };
                    manheimModel.Sellers.Add(sellerEntity);
                    manheimModel.SaveChanges();
                }
                #endregion

                #region PreSale
                var preSale = new Model.PreSale()
                {
                    Ln       = int.Parse(tds[0].Text.Split('-')[0]),
                    Run      = int.Parse(tds[0].Text.Split('-')[1]),
                    SaleDate = saleDate
                };
                lock (auctionEntity) {
                    preSale.Vehicle = vehicleEntity;
                    preSale.Auction = auctionEntity;
                    preSale.Seller  = sellerEntity;
                    manheimModel.PreSales.Add(preSale);
                }
                #endregion
                manheimModel.SaveChanges();
            }
        }
Ejemplo n.º 47
0
 public static void MyClassInitialize(TestContext testContext)
 {
     ie = new IE("www.google.com");
 }
Ejemplo n.º 48
0
 public NotifyAction(NotifyMethod method, awaDAL.DAL dal, WatiN.Core.IE ie, SiteObject target)
     : base(dal, ie, target)
 {
     this.notifyMethod = method;
 }
 public IEWaitForComplete(IE ie) : base(ie)
 {
     _ie = ie;
 }
 public IEWaitForComplete(IE ie, int waitForCompleteTimeOut) : base(ie, waitForCompleteTimeOut)
 {
     _ie = ie;
 }
Ejemplo n.º 51
0
        public void TestWebUIButton1()
        {
            var input = 123;

            string[] Headers = { "All Numbers:",
                                 "All Odd Numbers:",
                                 "All Even Numbers:",
                                 "All Extended FizzBuzzs:",
                                 "All Fibonacci Numbers:" };

            using (var browser = new WatiN.Core.IE(testUrl))
            {
                browser.TextField(Find.ByName("txtNumber")).TypeText(input.ToString());
                browser.Button(Find.ByName("btnGenerate")).Click();
                browser.WaitForComplete();
                //check each div has content
                var hIdx = 0;

                //sequence objects
                var allNumbers = new AllNumbers();
                var allEven    = new AllEvenNumbers();
                var allOdd     = new AllOddNumbers();
                var allFizz    = new AllExtendedFizzBuzzs();
                var allFib     = new AllFibonacciNumbers();

                foreach (var div in browser.Divs)
                {
                    var h = Headers[hIdx];
                    //check bold txt
                    if (div.Children().Count != 1)
                    {
                        Assert.Fail("Missing or extra bold header of " + h);
                    }
                    else
                    {
                        var boldHeader = div.Children()[0];
                        Assert.IsTrue(boldHeader.OuterHtml.Equals(string.Format("<b>{0}</b>", h)));
                    }

                    switch (hIdx)
                    {
                    case 0:
                        var allNumberSequence = string.Join(", ", allNumbers.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allNumberSequence)));
                        break;

                    case 1:
                        var allOddSequence = string.Join(", ", allOdd.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allOddSequence)));
                        break;

                    case 2:
                        var allEvenSequence = string.Join(", ", allEven.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allEvenSequence)));
                        break;

                    case 3:
                        var allFizzSequence = string.Join(", ", allFizz.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allFizzSequence)));
                        break;

                    case 4:
                        var allFibSequence = string.Join(", ", allFib.CreateSequence(input));
                        Assert.IsTrue(div.Text.Equals(string.Format("{0} {1} ", h, allFibSequence)));
                        break;
                    }
                    hIdx++;
                }
            }
        }
Ejemplo n.º 52
-1
        public string PassportCheck()
        {
            string strreturn = "";
            using (var browser = new IE("https://www.world-check.com/portal/mod_perl/Login/"))
            {
                if (Find.ByName("username"))
                {
                    browser.TextField(Find.ByName("username")).TypeText("nzrbrt0002");
                    browser.TextField(Find.ByName("password")).TypeText("Go8ahE5s");
                    browser.Image(Find.ByName("submitted")).Click();
                }

                browser.GoTo("https://www.world-check.com/portal/mod_perl/PassportCheck");

                browser.TextField(Find.ByName("givenName")).TypeText("Jim");
                browser.TextField(Find.ByName("lastName")).TypeText("Smith");
                browser.RadioButton(Find.ByName("sexg") && Find.ByValue("M")).Click();
                browser.Span(Find.ById("issuingState-CAN")).Click();
                browser.TextField(Find.ByName("dateOfBirthDay")).TypeText("29");
                browser.TextField(Find.ByName("dateOfBirthMonth")).TypeText("05");
                browser.TextField(Find.ByName("dateOfBirthYear")).TypeText("1978");
                browser.TextField(Find.ByName("passportNumber")).TypeText("WL745488");
                browser.TextField(Find.ByName("expireDateDay")).TypeText("10");
                browser.TextField(Find.ByName("expireDateMonth")).TypeText("07");
                browser.TextField(Find.ByName("expireDateYear")).TypeText("2014");
                browser.Button(Find.ByValue("VERIFY")).Click();

                var element = browser.Element(Find.ByClass("tablelinespacer"));
                var firsttd = element.NextSibling.NextSibling;
                strreturn = firsttd.Text.Replace("Lower Line:","");
                //Assert.IsTrue(browser.ContainsText("WatiN"));
            }
            return strreturn;
        }
Ejemplo n.º 53
-2
 public void Purge(IE ie)
 {
     var trash = ie.Page<Trash>();
     ie.GoTo(trash.Url);
     ie.WaitForComplete();
     trash.PurgeAll.Click();
 }