Exemplo n.º 1
1
        public static IWebElement UntilVisible(IWebElement element, TimeSpan timeOut)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();

            while (true)
            {
                WebDriverException lastException = null;
                try
                {
                    if (element.Displayed)
                    {
                        return element;
                    }
                    System.Threading.Thread.Sleep(100);
                }
                catch (ElementNotVisibleException e)     { lastException = e; }
                catch (NoSuchElementException e)         { lastException = e; }
                catch (StaleElementReferenceException e) { lastException = e; }

                if (sw.Elapsed > timeOut)
                {
                    string exceptionMessage = lastException == null ? "" : lastException.Message;
                    string errorMessage = string.Format("Wait.UntilVisible: Element was not displayed after {0} Milliseconds" +
                                                        "\r\n Error Message:\r\n{1}", timeOut.TotalMilliseconds, exceptionMessage);
                    throw new TimeoutException(errorMessage);
                }
            }
        }
        public void SetUpForFindElementsAndCreateActionsClass()
        {
            this.textBox = this.MainWindow.FindElement(By.Id("TextBox1"));
            this.button = this.MainWindow.FindElement(By.Id("SetTextButton"));

            this.action = new Actions(this.Driver);
        }
Exemplo n.º 3
0
 public static string GetButtonText(By locator)
 {
     element = GenericHelper.GetElement(locator);
     if (element.GetAttribute("value") == null)
         return String.Empty;
     return element.GetAttribute("value");
 }
        public static string GetElementXPath(IWebElement webElement, IWebDriver webDriver)
        {
            IJavaScriptExecutor jsExec = webDriver as IJavaScriptExecutor;
            return (string)jsExec.ExecuteScript(
            @"
            function getPathTo(element) {
            if (element === document.body)
            return '/html/' + element.tagName.toLowerCase();

            var ix = 0;
            var siblings = element.parentNode.childNodes;
            for (var i = 0; i < siblings.length; i++) {
            var sibling = siblings[i];
            if (sibling === element)
            {
            return getPathTo(element.parentNode) + '/' + element.tagName.toLowerCase() + '[' + (ix + 1) + ']';
            }
            if (sibling.nodeType === 1 && sibling.tagName === element.tagName)
            ix++;
            }
            }

            var element = arguments[0];
            var xpath = '';
            xpath = getPathTo(element);
            return xpath;
            ", webElement);
        }
Exemplo n.º 5
0
        public static Point GetElementLocation(IWebElement element)
        {
            Point location = GetElementOrigin(element);
            Size size = GetElementSize(element);

            return new Point(location.X + size.Width / 2, location.Y + size.Height / 2);
        }
        private void generateSequence(
            TranscriptCmdletBase cmdlet,
            System.Collections.Generic.List<IRecordedCodeSequence> recordingsCollection,
            IRecordedCodeSequence codeSequence,
            IWebElement firstElement,
            IWebElement secondElement)
        {
            Recorder.RecordingCollection = recordingsCollection;

            codeSequence = 
                Recorder.RecordCodeSequence(
                    cmdlet,
                    Recorder.RecordingCollection,
                    firstElement,
                    codeSequence);

            if (null != secondElement) {
                codeSequence = 
                    Recorder.RecordCodeSequence(
                        cmdlet,
                        Recorder.RecordingCollection,
                        secondElement,
                        codeSequence);
            }
            
            Recorder.StoreCodeSequenceInCollection(
                cmdlet,
                Recorder.RecordingCollection,
                codeSequence);
        }
Exemplo n.º 7
0
        protected override void execute(IWebElement element, IDictionary<string, object> cellValues, IStep step, ITestContext context)
        {
            assertCondition(element.Enabled, DisabledElementMessage);
            assertCondition(element.Displayed, HiddenElementMessage);

            element.Click();
        }
Exemplo n.º 8
0
 public static Point GetElementPositionWithinUsableViewport(this IWebDriver driver, IWebElement element)
 {
     var elementRect = new Rectangle(element.Location.X, element.Location.Y, element.Size.Width, element.Size.Height);
     var scrollY = elementRect.Top;
     var scrollX = elementRect.Left;
     return new Point(scrollX, scrollY);
 }
Exemplo n.º 9
0
		public LikeButton(IWebElement like)
		{
			if (like == null)
				throw new NotFoundException("like button not found");
			this.like = like;
			isLiked = UlearnDriver.HasCss(like, "btn-primary");
		}
Exemplo n.º 10
0
        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            var options = findOptions(element);
            foreach (var option in options)
            {
                if (option.Text == data.ToString())
                {
                    option.Click();
                    return;
                }
            }

            foreach (var option in options)
            {
                if (option.GetAttribute("value") == data.ToString())
                {
                    option.Click();
                    return;
                }
            }

            var message = "Cannot find the desired option\nThe available options are\nDisplay/Key\n";
            foreach (var option in options)
            {
                message += "\n" + "{0}/{1}".ToFormat(option.Text, option.GetAttribute("value"));
            }

            StoryTellerAssert.Fail(message);
        }
Exemplo n.º 11
0
        protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
        {
            var resolvedText = Test.ResolveMacros(Text);
            var resolvedValue = Test.ResolveMacros(Value);

            var isValue = String.IsNullOrWhiteSpace(resolvedText);

            var stringComparison = IsCaseSensitive
                ? StringComparison.InvariantCulture
                : StringComparison.InvariantCultureIgnoreCase;

            var option = isValue
                ? element.GetOptionByValue(resolvedValue, stringComparison)
                : element.GetOptionByText(resolvedText, stringComparison);

            if (option == null)
            {
                var key = isValue ? "Value" : "Text";
                var value = isValue ? resolvedValue : resolvedText;
                var message = String.Format("Unable to locate option by {0}: {1}", key, value);
                throw new Exception(message);
            }

            var isSelected = option.IsSelected();

            if (IsFalseExpected)
                Assert.False(isSelected);
            else
                Assert.True(isSelected);
        }
Exemplo n.º 12
0
 protected override void Execute(IWebDriver driver, dynamic context, IWebElement element)
 {
     if (IsFalseExpected)
         Assert.False(element.Enabled);
     else
         Assert.True(element.Enabled);
 }
Exemplo n.º 13
0
 public ButtonHandler(string id)
 {
     using (var driver = new ChromeDriver())
     {
         item = driver.FindElementById(id);
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Like decorator
 /// </summary>
 /// <param name="realWebElement"></param>
 public FakeWebElement(IWebElement realWebElement)
 //public WebElementDecorator(RemoteWebElement realWebElement) // : base(realWebElement.WrappedDriver, "")
 {
     this.DecoratedWebElement = realWebElement as FakeWebElement;
     this.SearchHistory =
         new List<ISearchHistory>();
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KendoTreeView"/> class.
 /// </summary>
 /// <param name="webElement">The webElement</param>
 public KendoTreeView(IWebElement webElement)
     : base(webElement.ToDriver() as RemoteWebDriver, null)
 {
     this.webElement = webElement;
     var id = webElement.GetAttribute("id");
     this.kendoTreeView = string.Format(CultureInfo.InvariantCulture, "$('#{0}').data('kendoTreeView')", id);
 }
Exemplo n.º 16
0
 public static void Check(IWebElement checkbox)
 {
     if (!IsChecked(checkbox))
     {
         checkbox.Click();
     }
 }
 public static void ScrollElementAndClick(IWebElement element)
 {
     Thread.Sleep(500);
     ExecuteScript("window.scrollTo(0," + element.Location.Y + ");");
     element.Click();
     Logger.Info(" Scroll Element And Click " + element);
 }
Exemplo n.º 18
0
		public TestHandler(IElementLocator elementLocator, IWebElement testElement, int testIndex) {
			this._elementLocator = elementLocator;
			this._testElement = testElement;
			this._testIndex = testIndex;

			Console.ForegroundColor = OutputColor;
		}
Exemplo n.º 19
0
 public static void OpenInNewTab(IWebElement item)
 {
     var url = item.FindElement(By.TagName("a"));
     url.SendKeys(Keys.Control + Keys.Return);
     url.SendKeys(Keys.Control + Keys.Tab);
     Cons.driver.SwitchTo().Window(Cons.driver.WindowHandles[Cons.driver.WindowHandles.Count - 1]);
 }
Exemplo n.º 20
0
        private void HandleElement(IWebElement el, IWebDriver browser, string[] parameters)
        {
            el.Clear();
            var keystroke = KeywordUtility.ReadParameterValue(_variables, parameters[2]);

            el.SendKeys(keystroke);
        }
Exemplo n.º 21
0
 public void ClickWebElement(String locator)
 {
     WaitForElementToLoad(locator);
     try
     {
         activeElement = theWebdriver.FindElement(By.Id(locator));
         while (!activeElement.Enabled)
         {
             Thread.Sleep(100);
         }
         activeElement.Click();
     }
     catch (StaleElementReferenceException e)
     {
         ClickWebElement(locator);
     }
     catch (System.InvalidOperationException e)
     {
         ClickWebElement(locator);
     }
     //catch (OpenQA.Selenium.InvalidElementStateException e)
     //{
     //    ClickWebElement(locator);
     //}
 }
Exemplo n.º 22
0
 public void NCTDoWork()
 {
     driver.Navigate().GoToUrl("http://thptnguyenchithanh.angiang.edu.vn/");
     //wait loading
     element = driver.FindElement(By.CssSelector("div[class='Head title_vis'] a>img[src$='DNN-plus.png']"));
     element.Click();
 }
Exemplo n.º 23
0
 protected override void Execute(IWebDriver driver, IWebElement element, CommandDesc command)
 {
     if (element.Selected)
     {
         element.Click();
     }
 }
Exemplo n.º 24
0
 public void WaitForAutocomplete(IWebElement el)
 {
     new WebDriverWait(driver, TimeSpan.FromSeconds(explTimeout)).Until<Boolean>(drv =>
     {
         return (el.Displayed && el.FindElements(By.CssSelector("li")).Count > 0);
     });
 }
Exemplo n.º 25
0
 protected BaseEmailEngager(Context context, IWebElement listItem) : base(context)
 {
     ListItem = listItem;
     DomainName = GetDomainName(listItem);
     CurrentDomain = context.GetDomain(DomainName);
     context.CurrentDomain = CurrentDomain;
 }
 public static void AssertElementsPresent(IWebElement[] elements, string elementDescription)
 {
     if (elements.Length == 0)
     {
         throw new AssertionException(String.Format("AssertElementsPresent Failed: Could not find '{0}'", elementDescription));
     }
 }
Exemplo n.º 27
0
        public ComponentScopeLocateResult Find(IWebElement scope, ComponentScopeLocateOptions options, SearchOptions searchOptions)
        {
            string labelXPath = new ComponentScopeXPathBuilder(options).
                WrapWithIndex(x => x.Descendant._("label")[y => y.TermsConditionOfContent]);

            IWebElement label = scope.Get(By.XPath(labelXPath).With(searchOptions).Label(options.GetTermsAsString()));

            if (label == null)
            {
                if (searchOptions.IsSafely)
                    return new MissingComponentScopeLocateResult();
                else
                    throw ExceptionFactory.CreateForNoSuchElement(options.GetTermsAsString(), searchContext: scope);
            }

            string elementId = label.GetAttribute("for");
            if (string.IsNullOrEmpty(elementId))
            {
                return new SequalComponentScopeLocateResult(label, new FindFirstDescendantStrategy());
            }
            else
            {
                ComponentScopeLocateOptions idOptions = options.Clone();
                idOptions.Terms = new[] { elementId };
                idOptions.Index = null;
                idOptions.Match = TermMatch.Equals;

                return new SequalComponentScopeLocateResult(scope, new FindByIdStrategy(), idOptions);
            }
        }
        private static IEnumerable<Row> GetTableBody(IWebElement tableElement)
        {
            var bodyElement = tableElement.FindElement(By.TagName("tbody"));
            var bodyRows = bodyElement.FindElements(By.TagName("tr"));

            var rows = new List<Row>();

            for (int rowIndex = 0; rowIndex < bodyRows.Count; rowIndex++)
            {
                var bodyRow = bodyRows[rowIndex];
                var cells = bodyRow.FindElements(By.TagName("td"));

                var row = new Row { Index = rowIndex };

                for (int columnIndex = 0; columnIndex < cells.Count; columnIndex++)
                {
                    var cell = cells[columnIndex];
                    row.Cells.Add(new Cell { ColumnId = columnIndex, Value = cell.Text, WebElement = cell });
                }

                rows.Add(row);
            }

            return rows;
        }
 public static void AssertElementPresent(IWebElement element, string elementDescription)
 {
     if (!IsElementPresent(element))
     {
         throw new AssertionException(String.Format("AssertElementPresent Failed: Could not find '{0}'", elementDescription));
     }
 }
Exemplo n.º 30
0
 public int ColumnCount(IWebElement element)
 {
     IList<IWebElement> tableRows = element.FindElements(By.CssSelector("tr"));
     IWebElement headerRow = tableRows[0];
     IList<IWebElement> tableCols = headerRow.FindElements(By.CssSelector("td"));
     return tableCols.Count();
 }
 public PageObjectC(IWebElement webElement, IPageObjectFactory pageFactory)
 {
     WebElement = webElement;
     PageFactory = pageFactory;
 }
Exemplo n.º 32
0
 public TableCellSe(IWebElement webElement)
     : base(webElement)
 {
 }
Exemplo n.º 33
0
 public static string GetId(this IWebElement webElement)
 {
     return(webElement.GetProperty("id"));
 }
Exemplo n.º 34
0
 public static void CheckCheckBox(By locator)
 {
     _element = GenericHelper.GetElement(locator);
     _element.Click();
 }
        public void ShouldBrowse()
        {
            // Open datepicker directive
            String      searchText = "Drop-down Datetime with input box";
            IWebElement contaiter  = null;

            try {
                contaiter = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(String.Format("//div[@class='col-sm-6']//*[contains(text(),'{0}')]", searchText))));
                ngDriver.Highlight(contaiter);
            } catch (Exception e) {
                Console.Error.WriteLine("Exception: " + e.ToString());
            }
            try {
                contaiter = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(String.Format("//*[text()[contains(.,'{0}')]]", searchText))));
                ngDriver.Highlight(contaiter);
            } catch (Exception e) {
                Console.Error.WriteLine("Exception: " + e.ToString());
            }

            NgWebElement ng_datepicker = ngDriver.FindElement(NgBy.Model("data.dateDropDownInput", "*[data-ng-app]"));

            Assert.IsNotNull(ng_datepicker);
            // ng_datepicker.Clear();
            ngDriver.Highlight(ng_datepicker);
            IWebElement calendar = ngDriver.FindElement(By.CssSelector(".input-group-addon"));

            ngDriver.Highlight(calendar);
            Actions actions = new Actions(ngDriver.WrappedDriver);

            actions.MoveToElement(calendar).Click().Build().Perform();

            IWebElement  dropdown    = driver.FindElement(By.CssSelector("div.dropdown.open ul.dropdown-menu"));
            NgWebElement ng_dropdown = new NgWebElement(ngDriver, dropdown);

            Assert.IsNotNull(ng_dropdown);
            NgWebElement ng_display = ngDriver.FindElement(NgBy.Binding("data.previousViewDate.display", true, "[data-ng-app]"));

            Assert.IsNotNull(ng_display);
            String datePattern = @"\d{4}\-(?<month>\w{3})";

            Regex datePatternReg = new Regex(datePattern);

            Assert.IsTrue(datePatternReg.IsMatch(ng_display.Text));
            ngDriver.Highlight(ng_display);
            String display_month = ng_display.Text.FindMatch(datePattern);

            String[] months =
            {
                "Jan",
                "Feb",
                "Mar",
                "Apr",
                "May",
                "Jun",
                "Jul",
                "Aug",
                "Sep",
                "Oct",
                "Dec",
                "Jan"
            };

            String next_month = months[Array.IndexOf(months, display_month) + 1];

            Console.Error.WriteLine("Current month: " + display_month);
            Console.Error.WriteLine("Expect to find next month: " + next_month);
            IWebElement ng_next_month = ng_display.FindElement(By.XPath("..")).FindElement(By.ClassName("right"));

            Assert.IsNotNull(ng_next_month);
            ngDriver.Highlight(ng_next_month, 100);
            ng_next_month.Click();
            Assert.IsTrue(ng_display.Text.Contains(next_month));
            ngDriver.Highlight(ng_display);
            Console.Error.WriteLine("Next month: " + ng_display.Text);
        }
        public void ShouldDirectSelect()
        {
            // Arrange
            try {
                wait.Until(e => e.FindElements(
                               By.ClassName("col-sm-6")).Any(element => element.Text.IndexOf("Drop-down Datetime with input box", StringComparison.InvariantCultureIgnoreCase) > -1));
            } catch (Exception e) {
                verificationErrors.Append(e.Message);
            }
            NgWebElement ng_datepicker = ngDriver.FindElement(NgBy.Model("data.dateDropDownInput", "*[data-ng-app]"));

            Assert.IsNotNull(ng_datepicker);
            // ng_datepicker.Clear();
            ngDriver.Highlight(ng_datepicker);
            IWebElement calendar = ngDriver.FindElement(By.CssSelector(".input-group-addon"));

            Assert.IsNotNull(calendar);
            ngDriver.Highlight(calendar);
            Actions actions = new Actions(ngDriver.WrappedDriver);

            actions.MoveToElement(calendar).Click().Build().Perform();

            IWebElement  dropdown    = driver.FindElement(By.CssSelector("div.dropdown.open ul.dropdown-menu"));
            NgWebElement ng_dropdown = new NgWebElement(ngDriver, dropdown);

            Assert.IsNotNull(ng_dropdown);
            ReadOnlyCollection <NgWebElement> elements = ng_dropdown.FindElements(NgBy.Repeater("dateObject in week.dates"));

            Assert.IsTrue(28 <= elements.Count);

            String      monthDate   = "12";
            IWebElement dateElement = ng_dropdown.FindElements(NgBy.CssContainingText("td.ng-binding", monthDate)).First();

            Console.Error.WriteLine("Mondh Date: " + dateElement.Text);
            dateElement.Click();
            NgWebElement ng_element = ng_dropdown.FindElement(NgBy.Model("data.dateDropDownInput", "[data-ng-app]"));

            Assert.IsNotNull(ng_element);
            ngDriver.Highlight(ng_element);
            ReadOnlyCollection <NgWebElement> ng_dataDates = ng_element.FindElements(NgBy.Repeater("dateObject in data.dates"));

            Assert.AreEqual(24, ng_dataDates.Count);

            String       timeOfDay = "6:00 PM";
            NgWebElement ng_hour   = ng_element.FindElements(NgBy.CssContainingText("span.hour", timeOfDay)).First();

            Assert.IsNotNull(ng_hour);
            ngDriver.Highlight(ng_hour);
            Console.Error.WriteLine("Hour of the day: " + ng_hour.Text);
            ng_hour.Click();
            String specificMinute = "6:35 PM";

            // no need to reload
            ng_element = ng_dropdown.FindElement(NgBy.Model("data.dateDropDownInput", "*[data-ng-app]"));
            Assert.IsNotNull(ng_element);
            ngDriver.Highlight(ng_element);
            NgWebElement ng_minute = ng_element.FindElements(NgBy.CssContainingText("span.minute", specificMinute)).First();

            Assert.IsNotNull(ng_minute);
            ngDriver.Highlight(ng_minute);
            Console.Error.WriteLine("Time of the day: " + ng_minute.Text);
            ng_minute.Click();
            ng_datepicker = ngDriver.FindElement(NgBy.Model("data.dateDropDownInput", "[data-ng-app]"));
            ngDriver.Highlight(ng_datepicker, 100);
            Console.Error.WriteLine("Selected Date/time: " + ng_datepicker.GetAttribute("value"));
        }
Exemplo n.º 37
0
 public TableCellSe(IWebElement webElement, By by, Func <ElementSe, bool> predicate)
     : base(webElement, by, predicate)
 {
 }
Exemplo n.º 38
0
 public TableCellSe(IWebElement webElement, By by)
     : base(webElement, by)
 {
 }
Exemplo n.º 39
0
 private bool IsAttributeOprtationType(IWebElement element, string attributeName, AttributeOperationType setAttributeType)
 {
     return(setAttributeType == AttributeOperationType.ForceAttribute ||
            (setAttributeType == AttributeOperationType.PreferAttribute && element.IsAttribute(attributeName)));
 }
Exemplo n.º 40
0
        public static SelectElement SelectFromList(IWebElement element)
        {
            SelectElement select = new SelectElement(element);

            return(select);
        }
Exemplo n.º 41
0
 public WebElement(IWebDriver webDriver, IWebElement webElement, By by)
 {
     _webDriver  = webDriver;
     _webElement = webElement;
     _by         = by;
 }
Exemplo n.º 42
0
 protected static void ClearAndSetValue(IWebElement element, string value)
 {
     element.Clear();
     element.SendKeys(value);
 }
Exemplo n.º 43
0
 private void VerifyWebElements()
 {
     IWebElement element = ProductComparisonLabel;
 }
 protected override void SetMemberValue(IWebElement element)
 {
     ((PropertyInfo)member).SetForce(this.Page, element);
 }
Exemplo n.º 45
0
        public void WhenIClickOnThe(string linkText)
        {
            IWebElement element = ElementHelper.WaitUntilElementIsVisible(Driver, HomePage.linkByText(linkText), 5);

            element.Click();
        }
Exemplo n.º 46
0
        public void SelectFirstTableEntity()
        {
            IWebElement entityRow = By.CssSelector("table > tbody > tr").FindElement(Browser.Driver);

            entityRow.Click();
        }
Exemplo n.º 47
0
        public void CheckCheckbox(IWebDriver driver, string xpath, bool value)
        {
            IWebElement checkBox = driver.FindElement(By.XPath(xpath));

            CheckCheckbox(checkBox, value);
        }
Exemplo n.º 48
0
        private IWebElement GetCellInRowByNum(IWebElement row, int num)
        {
            var cell = row.FindElements(By.XPath(".//td")).ToList()[num - 1];

            return(cell);
        }
 public ElementA(IWebElement webElement) : base(webElement)
 {
 }
Exemplo n.º 50
0
 public static bool IsButonEnabled(By locator)
 {
     element = GenericHelper.GetElement(locator);
     return element.Enabled;
 }
Exemplo n.º 51
0
 public static bool IsTypeReset(this IWebElement webElement)
 {
     return(GetType(webElement).Equals("reset", StringComparison.InvariantCultureIgnoreCase));
 }
 public PageObjectB(IWebElement webElement)
 {
     WebElement = webElement;
 }
Exemplo n.º 53
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Browser = new OpenQA.Selenium.Chrome.ChromeDriver();
            Browser.Manage().Window.Maximize();
            Browser.Navigate().GoToUrl("https://vk.com");
            IWebElement login = Browser.FindElement(By.Id("index_email"));

            login.SendKeys("*");
            IWebElement password = Browser.FindElement(By.Id("index_pass"));

            password.SendKeys("* " + OpenQA.Selenium.Keys.Enter);
            System.Threading.Thread.Sleep(3000);
            Browser.Navigate().GoToUrl("https://vk.com/bigmarketcrimea");
            while (true)
            {
Point:
                try
                {
                    System.Threading.Thread.Sleep(3000);
                    IWebElement Post = Browser.FindElement(By.XPath("//*[text()='только что']"));
                    Post.Click();
                }
                catch (NoSuchElementException)
                {
                    System.Threading.Thread.Sleep(10000);
                    Browser.Navigate().Refresh();
                    goto Point;
                }
                System.Threading.Thread.Sleep(5000);

                string PostNumber = Browser.Url;
                System.Threading.Thread.Sleep(1000);
                string PostNumberCut = PostNumber.Remove(0, 46);

                string s1;
                string s2 = "Falbum";


                int k = 1;
                Browser.Navigate().GoToUrl("https://vk.com/bigmarketcrimea?w=wall-104414442_" + PostNumberCut);
                System.Threading.Thread.Sleep(5000);
                string Trigger = "";
                int    i       = 0;
                try
                {
                    Trigger = Browser.FindElement(By.CssSelector("#wpt-104414442_" + PostNumberCut + " > div.wall_post_text")).Text;
                    //  IWebElement link = Browser.FindElement(By.CssSelector("#wpt-104414442_" + post_string + " > div.wall_signed > a "));
                    System.Threading.Thread.Sleep(3000);
                    IWebElement Photo = Browser.FindElement(By.CssSelector("#wpt-104414442_" + PostNumberCut + " > div.page_post_sized_full_thumb.page_post_sized_full_thumb_first > div > a"));
                    Photo.Click();

                    while (true)
                    {
                        try
                        {
                            System.Threading.Thread.Sleep(3000);

                            IWebElement SaveBtn = Browser.FindElement(By.CssSelector("#pv_save_to_me"));
                            SaveBtn.Click();
                            System.Threading.Thread.Sleep(3000);
                            IWebElement PhotoFull = Browser.FindElement(By.CssSelector("#pv_photo"));
                            PhotoFull.Click();
                            i++;
                            s1 = Browser.Url;
                            bool b = s1.Contains(s2);
                            if (b == true)
                            {
                                goto marker2;
                            }
                        }
                        catch (NoSuchElementException)
                        {
                            goto Point2;
                        }
                        finally
                        {
                        }
                    }
Point2:
marker2:
                    System.Threading.Thread.Sleep(3000);
                    k = i;
                    Browser.Navigate().GoToUrl("https://vk.com/bigmarketcrimea?w=wall-104414442_" + PostNumberCut);
                    IWebElement Link = Browser.FindElement(By.CssSelector("#wpt-104414442_" + PostNumberCut + " > div.wall_signed > a "));
                    System.Threading.Thread.Sleep(3000);
                    Link.Click();
                }
                catch (NoSuchElementException)
                {
                    goto Point;
                }
                finally
                {
                    if (Trigger == "")
                    {
                        goto point;
                    }
                    System.Threading.Thread.Sleep(3000);
                    string CrntURL = Browser.Url;
                    Browser.Navigate().GoToUrl("https://vk.com/public198570678");
                    System.Threading.Thread.Sleep(3000);
                    IWebElement Test = Browser.FindElement(By.Id("post_field"));
                    Test.SendKeys(Trigger + "\n\n");
                    Test.SendKeys(CrntURL);
                    for (int j = 0; j < i; j++)
                    {
                        IWebElement PickPhoto = Browser.FindElement(By.CssSelector("#page_add_media > div.media_selector.clear_fix > a.ms_item.ms_item_photo._type_photo"));
                        PickPhoto.Click();
                        System.Threading.Thread.Sleep(3000);

                        IWebElement Photo = Browser.FindElement(By.XPath("/html/body/div[6]/div[1]/div[2]/div/div[2]/div/div[2]/div[3]/a[" + k + "]"));
                        Photo.Click();
                        k--;
                    }


                    IWebElement Click = Browser.FindElement(By.Id("send_post"));
                    Click.Click();

point:
                    System.Threading.Thread.Sleep(3000);
                    File.WriteAllText("C:/save.txt", PostNumberCut);
                }
            }
        }
Exemplo n.º 54
0
        public string FTP_LexingtonSC(string address, string parcelNumber, string ownername, string searchType, string orderNumber, string directParcel)
        {
            GlobalClass.global_orderNo             = orderNumber;
            HttpContext.Current.Session["orderNo"] = orderNumber;
            GlobalClass.global_parcelNo            = parcelNumber;
            var driverService = PhantomJSDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            List <string> PdfDownloadlink = new List <string>();
            string        StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = "";
            string        Parcel_number = "", Tax_Authority = "", TaxSale = "", Delinquent_Tax = "", Propertyresult = "", LastYear = "", LegalDescription = "", Addresshrf = "", duedata = "";

            // driver = new ChromeDriver();
            // driver = new PhantomJSDriver();
            using (driver = new PhantomJSDriver())//PhantomJSDriver
            {
                try
                {
                    StartTime = DateTime.Now.ToString("HH:mm:ss");
                    if (searchType == "titleflex")
                    {
                        string titleaddress = address;
                        gc.TitleFlexSearch(orderNumber, "", "", titleaddress, "SC", "Lexington");

                        if (HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes")
                        {
                            driver.Quit();
                            return("MultiParcel");
                        }
                        parcelNumber = HttpContext.Current.Session["titleparcel"].ToString();
                        searchType   = "parcel";
                        if (parcelNumber.Trim() == "")
                        {
                            HttpContext.Current.Session["Nodata_LexingtonSC"] = "Yes";
                            driver.Quit();
                            return("No Data Found");
                        }
                    }
                    driver.Navigate().GoToUrl("http://www.lex-co.com/PCSearch/TaxInfoPropertySearch.asp");
                    if (searchType == "address")
                    {
                        driver.FindElement(By.XPath("//*[@id='parcelINQ']/table/tbody/tr[4]/td[2]/input")).SendKeys(address);
                        gc.CreatePdf_WOP(orderNumber, "SearchBefore", driver, "SC", "Lexington");
                        driver.FindElement(By.XPath("//*[@id='parcelINQ']/table/tbody/tr[11]/td/input")).Click();
                        Thread.Sleep(2000);
                        int Max = 0;
                        try
                        {
                            string              Pin = "";
                            IWebElement         Multiparceladdress = driver.FindElement(By.XPath("//*[@id='divcenter']/table"));
                            IList <IWebElement> Multiparcelrow     = Multiparceladdress.FindElements(By.TagName("tr"));
                            IList <IWebElement> Multiparcelid;
                            gc.CreatePdf_WOP(orderNumber, "SearchAfter", driver, "SC", "Lexington");
                            string currentyear = DateTime.Now.Year.ToString();
                            foreach (IWebElement multiparcel in Multiparcelrow)
                            {
                                Multiparcelid = multiparcel.FindElements(By.TagName("td"));
                                if (Multiparcelid.Count != 0 && currentyear.Trim() == Multiparcelid[0].Text.Trim())
                                {
                                    Address1   = Multiparcelid[1].FindElement(By.TagName("a"));
                                    Addresshrf = Address1.GetAttribute("href");
                                    // string Stnumber = Multiparcelid[1].Text;
                                    string Owner  = Multiparcelid[2].Text;
                                    string street = Multiparcelid[3].Text;
                                    //string Unit = Multiparcelid[4].Text;
                                    string Addressst = Owner + "~" + street;
                                    // string Owner = Multiparcelid[1].Text;
                                    Pin = Address1.Text;
                                    // string Multiparcel = Addressst;
                                    gc.insert_date(orderNumber, Pin, 1706, Addressst, 1, DateTime.Now);
                                    Max++;
                                }
                                if (Multiparcelid.Count != 0 && Multiparcelid[0].Text.Trim() != "")
                                {
                                    LastYear = Multiparcelid[0].Text;
                                }
                            }
                            Multiparcelrow.Reverse();
                            int rows_count1 = Multiparcelrow.Count;

                            if (Addresshrf == "")
                            {
                                for (int row = 0; row < rows_count1; row++)
                                {
                                    IList <IWebElement> Columns_row = Multiparcelrow[row].FindElements(By.TagName("td"));
                                    int columns_count = Columns_row.Count;
                                    if (columns_count != 0 && Columns_row[0].Text.Trim() == LastYear)
                                    {
                                        Address1   = Columns_row[1].FindElement(By.TagName("a"));
                                        Addresshrf = Address1.GetAttribute("href");
                                        Max++;
                                        break;
                                    }
                                }
                            }
                            if (Max == 1)
                            {
                                driver.Navigate().GoToUrl(Addresshrf);
                                Thread.Sleep(2000);
                            }
                            if (Max > 1 && Max < 26)
                            {
                                HttpContext.Current.Session["multiParcel_Lexington"] = "Maximum";
                                driver.Quit();
                                return("MultiParcel");
                            }
                            if (Max > 25)
                            {
                                HttpContext.Current.Session["multiParcel_Lexington_Multicount"] = "Maximum";
                                driver.Quit();
                                return("Maximum");
                            }
                            if (Max == 0)
                            {
                                HttpContext.Current.Session["Nodata_LexingtonSC"] = "Yes";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }
                    if (searchType == "parcel")
                    {
                        driver.FindElement(By.XPath("//*[@id='parcelINQ']/table/tbody/tr[2]/td[2]/input")).SendKeys(parcelNumber.Replace("-", ""));
                        gc.CreatePdf(orderNumber, parcelNumber, "Parcel Search", driver, "SC", "Lexington");
                        driver.FindElement(By.XPath("//*[@id='parcelINQ']/table/tbody/tr[11]/td/input")).Click();
                        Thread.Sleep(2000);
                        int Max = 0;
                        try
                        {
                            IWebElement         Multiparceladdress = driver.FindElement(By.XPath("//*[@id='divcenter']/table"));
                            IList <IWebElement> Multiparcelrow     = Multiparceladdress.FindElements(By.TagName("tr"));
                            IList <IWebElement> Multiparcelid;
                            gc.CreatePdf_WOP(orderNumber, "SearchAfter", driver, "SC", "Lexington");
                            string currentyear = DateTime.Now.Year.ToString();
                            foreach (IWebElement multiparcel in Multiparcelrow)
                            {
                                Multiparcelid = multiparcel.FindElements(By.TagName("td"));
                                if (Multiparcelid.Count != 0 && currentyear.Trim() == Multiparcelid[0].Text.Trim())
                                {
                                    Address1   = Multiparcelid[1].FindElement(By.TagName("a"));
                                    Addresshrf = Address1.GetAttribute("href");
                                    driver.Navigate().GoToUrl(Addresshrf);
                                    break;
                                }
                            }
                        }
                        catch { }
                    }
                    //if (searchType == "ownername")
                    //{
                    //    driver.FindElement(By.XPath("//*[@id='parcelINQ']/table/tbody/tr[3]/td[2]/input")).SendKeys(ownername);
                    //    driver.FindElement(By.XPath("//*[@id='parcelINQ']/table/tbody/tr[11]/td/input")).Click();
                    //    int Max = 0;
                    //    try
                    //    {
                    //        IWebElement Multiparceladdress = driver.FindElement(By.XPath("//*[@id='divcenter']/table"));
                    //        IList<IWebElement> Multiparcelrow = Multiparceladdress.FindElements(By.TagName("tr"));
                    //        IList<IWebElement> Multiparcelid;
                    //        gc.CreatePdf_WOP(orderNumber, "SearchAfter", driver, "SC", "Lexington");
                    //        string currentyear = DateTime.Now.Year.ToString();
                    //        foreach (IWebElement multiparcel in Multiparcelrow)
                    //        {
                    //            Multiparcelid = multiparcel.FindElements(By.TagName("td"));
                    //            if (Multiparcelid.Count != 0)
                    //            {
                    //                Address1 = Multiparcelid[1].FindElement(By.TagName("a"));
                    //                Addresshrf = Address1.GetAttribute("href");
                    //                // string Stnumber = Multiparcelid[1].Text;
                    //                string Owner = Multiparcelid[2].Text;
                    //                string street = Multiparcelid[3].Text;
                    //                //string Unit = Multiparcelid[4].Text;
                    //                string Addressst = Owner + "~" + street;
                    //                // string Owner = Multiparcelid[1].Text;
                    //                string Pin = Address1.Text;
                    //                // string Multiparcel = Addressst;
                    //                gc.insert_date(orderNumber, Pin, 1706, Addressst, 1, DateTime.Now);
                    //                Max++;
                    //            }
                    //        }
                    //        if (Max == 1)
                    //        {
                    //            driver.Navigate().GoToUrl(Addresshrf);
                    //            Thread.Sleep(2000);
                    //        }
                    //        if (Max > 1 && Max < 26)
                    //        {
                    //            HttpContext.Current.Session["multiParcel_Lexington"] = "Maximum";
                    //            driver.Quit();
                    //            return "MultiParcel";
                    //        }
                    //        if (Max > 25)
                    //        {
                    //            HttpContext.Current.Session["multiParcel_Lexington_Multicount"] = "Maximum";
                    //            driver.Quit();
                    //            return "Maximum";
                    //        }
                    //        if (Max == 0)
                    //        {
                    //            HttpContext.Current.Session["Nodata_LexingtonSC"] = "Yes";
                    //            driver.Quit();
                    //            return "No Data Found";
                    //        }
                    //    }
                    //    catch { }
                    //}

                    //try
                    //{
                    //    IWebElement INodata = driver.FindElement(By.Id("divcenter"));
                    //    if(INodata.Text.Contains("search produced no results"))
                    //    {
                    //        HttpContext.Current.Session["Nodata_LexingtonSC"] = "Yes";
                    //        driver.Quit();
                    //        return "No Data Found";
                    //    }
                    //}
                    //catch { }

                    string Propertytable = driver.FindElement(By.XPath("//*[@id='divcenter']/table[1]/tbody/tr/td/table/tbody")).Text;
                    Parcel_number = gc.Between(Propertytable, "TMS#:", "TAX YEAR:");
                    string owner           = gc.Between(Propertytable, "OWNER:", "ADDRESS:");
                    string MailingAddress  = gc.Between(Propertytable, "ADDRESS:", "PROPERTY ADDRESS:");
                    string propertyaddress = gc.Between(Propertytable, "PROPERTY ADDRESS:", "LEGAL DESCRIPTION:");
                    if (Propertytable.Contains("DEED BOOK & PAGE:"))
                    {
                        LegalDescription = gc.Between(Propertytable, "LEGAL DESCRIPTION:", "DEED BOOK & PAGE:");
                    }
                    if (Propertytable.Contains("PLAT:"))
                    {
                        LegalDescription = gc.Between(Propertytable, "LEGAL DESCRIPTION:", "PLAT:");
                    }
                    string LandUse      = gc.Between(Propertytable, "LAND USE:", "TAX DISTRICT:");
                    string Yearbuilt    = driver.FindElement(By.XPath("//*[@id='divcenter']/table[2]/tbody/tr/td[2]/table/tbody/tr[4]/td[2]")).Text;
                    string AssessedYear = gc.Between(Propertytable, "TAX YEAR:", "OWNER:");
                    Propertyresult = owner + "~" + propertyaddress + "~" + MailingAddress + "~" + Yearbuilt + "~" + LegalDescription + "~" + LandUse + "~" + AssessedYear;
                    gc.insert_date(orderNumber, Parcel_number, 1707, Propertyresult, 1, DateTime.Now);
                    gc.CreatePdf(orderNumber, parcelNumber, "Assessment", driver, "SC", "Lexington");
                    IWebElement         AssessmentInfoTable = driver.FindElement(By.XPath("//*[@id='divcenter']/table[2]/tbody/tr/td[1]/table/tbody"));
                    IList <IWebElement> AssessmentInforow   = AssessmentInfoTable.FindElements(By.TagName("tr"));
                    IList <IWebElement> AssessmentInfoid;
                    foreach (IWebElement AssessmentInfo in AssessmentInforow)
                    {
                        AssessmentInfoid = AssessmentInfo.FindElements(By.TagName("td"));
                        if (AssessmentInfoid.Count != 0 & !AssessmentInfo.Text.Contains("ASSESSMENT INFORMATION"))
                        {
                            string AssessmentInfoResult = AssessmentInfoid[0].Text + "~" + AssessmentInfoid[1].Text;
                            gc.insert_date(orderNumber, Parcel_number, 1720, AssessmentInfoResult, 1, DateTime.Now);
                        }
                    }
                    AssessmentTime = DateTime.Now.ToString("HH:mm:ss");
                    //Tax
                    driver.Navigate().GoToUrl("http://www.lex-co.com/PCSearch/TaxInfoPropertySearch.asp");
                    driver.FindElement(By.XPath("//*[@id='taxINQ']/table/tbody/tr/td[1]/table/tbody/tr[2]/td[2]/input")).SendKeys(Parcel_number.Replace("-", "").Trim());
                    gc.CreatePdf(orderNumber, parcelNumber, "Tax search", driver, "SC", "Lexington");
                    driver.FindElement(By.XPath("//*[@id='taxINQ']/table/tbody/tr/td[1]/table/tbody/tr[6]/td/input")).Click();
                    Thread.Sleep(2000);
                    gc.CreatePdf(orderNumber, parcelNumber, "Tax search Result", driver, "SC", "Lexington");
                    try
                    {
                        string Nodata = driver.FindElement(By.XPath("//*[@id='page']/div[2]/p[2]/font")).Text;
                        if (Nodata.Contains("Your search produced"))
                        {
                            HttpContext.Current.Session["Nodata_LexingtonSC"] = "Yes";
                            driver.Quit();
                            return("No Data Found");
                        }
                    }
                    catch { }
                    IWebElement         TaxSearchTable = driver.FindElement(By.XPath("//*[@id='page']/div[2]/table"));
                    IList <IWebElement> TaxSearchrow   = TaxSearchTable.FindElements(By.TagName("tr"));
                    //TaxSearchrow.Reverse();
                    IList <IWebElement> TaxSearchid;
                    //int rows_count = TaxSearchrow.Count - 1;
                    foreach (IWebElement TaxSearch in TaxSearchrow)
                    {
                        TaxSearchid = TaxSearch.FindElements(By.TagName("td"));

                        if (TaxSearchid.Count != 0 && TaxSearchid[0].Text.Trim() != "")
                        {
                            string taxSearchResult = TaxSearchid[0].Text + "~" + TaxSearchid[1].Text + "~" + TaxSearchid[2].Text + "~" + TaxSearchid[3].Text + "~" + TaxSearchid[4].Text + "~" + TaxSearchid[5].Text + "~" + TaxSearchid[6].Text;
                            gc.insert_date(orderNumber, Parcel_number, 1717, taxSearchResult, 1, DateTime.Now);
                        }
                        if (TaxSearchid.Count != 0 && TaxSearchid[4].Text.Contains("TAX"))
                        {
                            TaxSale = "Please contact county for tax information" + "~" + "";
                            gc.insert_date(orderNumber, Parcel_number, 1726, TaxSale, 1, DateTime.Now);
                        }
                    }

                    List <string>       ParcelSearch = new List <string>();
                    IWebElement         ParcelTB     = driver.FindElement(By.XPath("//*[@id='page']/div[2]/table"));
                    IList <IWebElement> ParcelTR     = ParcelTB.FindElements(By.TagName("tr"));
                    ParcelTR.Reverse();
                    int rows_count = ParcelTR.Count - 1;

                    for (int row = 0; row < rows_count; row++)
                    {
                        if (row == rows_count - 3 || row == rows_count - 1 || row == rows_count - 5)
                        {
                            IList <IWebElement> Columns_row = ParcelTR[row].FindElements(By.TagName("td"));
                            int columns_count = Columns_row.Count;
                            if (columns_count != 0)
                            {
                                IWebElement ParcelBill_link = Columns_row[0].FindElement(By.TagName("a"));
                                string      Parcelurl       = ParcelBill_link.GetAttribute("href");
                                ParcelSearch.Add(Parcelurl);
                            }
                        }
                    }
                    TaxTime = DateTime.Now.ToString("HH:mm:ss");
                    foreach (string taxlink in ParcelSearch)
                    {
                        driver.Navigate().GoToUrl(taxlink);
                        Thread.Sleep(2000);
                        string addres1            = driver.FindElement(By.XPath("//*[@id='divcenter']/table[3]/tbody/tr[3]")).Text.Trim();
                        string address2           = driver.FindElement(By.XPath("//*[@id='divcenter']/table[3]/tbody/tr[4]")).Text;
                        string address3           = addres1 + address2;
                        string Billtable          = driver.FindElement(By.XPath("//*[@id='divcenter']/table[2]/tbody")).Text;
                        string Bill               = gc.Between(Billtable, "Bill#", "TxYr");
                        string TaxYear            = gc.Between(Billtable, "TxYr", "Rev#");
                        string Owner              = driver.FindElement(By.XPath("//*[@id='divcenter']/table[3]/tbody/tr[2]")).Text;
                        string TaxFeestable       = driver.FindElement(By.XPath("//*[@id='divcenter']/table[4]/tbody")).Text;
                        string Taxamount          = gc.Between(TaxFeestable, "TAXES", "COSTS");
                        string credit             = gc.Between(TaxFeestable, "CREDIT/RELIEF", "FEES");
                        string HomesteadExemption = gc.Between(TaxFeestable, "H/S EMPT", "TOTAL");
                        string Penalty            = gc.Between(TaxFeestable, "PENALTY", "PAID");
                        string Interest           = gc.Between(TaxFeestable, "INTERNET/INTEREST", "REFUND");
                        string Costs              = gc.Between(TaxFeestable, "COSTS", "ASMT DEDCT");
                        string Fees               = gc.Between(TaxFeestable, "FEES", "ADJ RATIO");
                        string Total              = gc.Between(TaxFeestable, "TOTAL", "# OF MONTHS");
                        string Paid               = gc.Between(TaxFeestable, "PAID", "Adj Value");
                        string Refund             = GlobalClass.After(TaxFeestable, "REFUND");
                        gc.CreatePdf(orderNumber, parcelNumber, "Tax search Result" + TaxYear, driver, "SC", "Lexington");
                        //property type
                        string      HomesteadPercentage = "";
                        IWebElement IHome = null;
                        try
                        {
                            IHome = driver.FindElement(By.XPath("//*[@id='divcenter']/center[2]/table/tbody"));
                        }
                        catch { }
                        try
                        {
                            if (IHome == null)
                            {
                                IHome = driver.FindElement(By.XPath("//*[@id='divcenter']/center[2]/table/tbody"));
                            }
                        }
                        catch { }
                        IList <IWebElement> IHomerow = IHome.FindElements(By.TagName("tr"));
                        IList <IWebElement> IHomeid;
                        foreach (IWebElement home in IHomerow)
                        {
                            IHomeid = home.FindElements(By.TagName("td"));
                            if (IHomeid.Count != 0 && home.Text.Contains("H/S%"))
                            {
                                for (int i = 0; i < IHomeid.Count; i++)
                                {
                                    string check = IHomeid[i].Text;
                                    try
                                    {
                                        if (check == "H/S%")
                                        {
                                            i++;
                                            HomesteadPercentage = IHomeid[i].Text;
                                            break;
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                        string Duedate1 = driver.FindElement(By.XPath("//*[@id='divcenter']/center[1]/b")).Text;
                        if (Duedate1.Contains("PENALTY DATE"))
                        {
                            duedata = gc.Between(Duedate1, "DUE BY", "PENALTY DATE");
                        }
                        else
                        {
                            duedata = GlobalClass.After(Duedate1, "DUE BY");
                        }
                        string TaxResult = address3 + "~" + Owner + "~" + Bill + "~" + TaxYear + "~" + Taxamount + "~" + duedata + "~" + credit + "~" + HomesteadExemption + "~" + Penalty + "~" + Interest + "~" + Costs + "~" + Fees + "~" + Total + "~" + Paid + "~" + Refund + "~" + HomesteadPercentage;
                        gc.insert_date(orderNumber, Parcel_number, 1725, TaxResult, 1, DateTime.Now);
                        if (!Penalty.Contains("0.00"))
                        {
                            Delinquent_Tax = "" + "~" + "Please contact county for tax information";
                            gc.insert_date(orderNumber, Parcel_number, 1726, TaxSale, 1, DateTime.Now);
                        }
                        Thread.Sleep(2000);
                        IWebElement LinkDownload = driver.FindElement(By.LinkText("View Current Tax Bill"));
                        // gc.downloadfile(Linkhref, orderNumber, Parcel_number.Replace("-", ""), "ViewTaxBill" + TaxYear.Trim(), "SC", "Lexington");
                        // gc.CreatePdf(orderNumber, parcelNumber, "ViewTaxBill" + TaxYear, driver, "SC", "Lexington");
                        //gc.downloadfile(Linkhref, orderNumber, Parcel_number.Replace("-",""), "ViewTaxBill"+ TaxYear.Trim(), "SC", "Lexington");
                        string Linkhref = LinkDownload.GetAttribute("href");
                        PdfDownloadlink.Add(Linkhref);
                        //driver.Navigate().GoToUrl(Linkhref);
                        //Thread.Sleep(8000);
                        //gc.CreatePdf(orderNumber, parcelNumber, "ViewTaxBill1" + TaxYear, driver, "SC", "Lexington");
                    }
                    foreach (string Pdfdownload in PdfDownloadlink)
                    {
                        string fileName          = "";
                        var    chromeOptions     = new ChromeOptions();
                        var    downloadDirectory = ConfigurationManager.AppSettings["AutoPdf"];
                        chromeOptions.AddUserProfilePreference("download.default_directory", downloadDirectory);
                        chromeOptions.AddUserProfilePreference("download.prompt_for_download", false);
                        chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true");
                        chromeOptions.AddUserProfilePreference("plugins.always_open_pdf_externally", true);
                        Array.ForEach(Directory.GetFiles(@downloadDirectory), File.Delete);
                        var chDriver = new ChromeDriver(chromeOptions);
                        try
                        {
                            chDriver.Navigate().GoToUrl(Pdfdownload);
                            Thread.Sleep(2000);
                            fileName = latestfilename();
                            //gc.AutoDownloadFile(orderNumber, Parcel_number, "Washington", "MN", "TaxBill" + m + ".pdf");
                            gc.AutoDownloadFile(orderNumber, Parcel_number, "Lexington", "SC", fileName);
                            chDriver.Quit();
                            // m++;
                        }
                        catch (Exception e)
                        {
                            chDriver.Quit();
                        }
                    }

                    LastEndTime = DateTime.Now.ToString("HH:mm:ss");
                    gc.insert_TakenTime(orderNumber, "SC", "Lexington", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime);
                    driver.Quit();
                    gc.mergpdf(orderNumber, "SC", "Lexington");
                    return("Data Inserted Successfully");
                }
                catch (Exception ex)
                {
                    driver.Quit();
                    throw ex;
                }
            }
        }
Exemplo n.º 55
0
 public CheckBox(By byLocator = null, IWebElement webElement = null)
     : base(byLocator, webElement)
 {
 }
Exemplo n.º 56
0
 public Button(IWebElement el, string name) : base(el, name)
 {
 }
Exemplo n.º 57
0
 public TextFieldSeCollection(IWebElement webElement, By by, Func<IWebElement, bool> predicate)
     : base(webElement, by, predicate)
 {
 }
Exemplo n.º 58
0
        public static void TrackWithoutBrowser()
        {
            // initialize a WebDriver instance
            IWebDriver    driver     = new PhantomJSDriver();
            WebDriverWait driverWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            driver.Manage().Window.Maximize();
            // load search page
            driver.Navigate().GoToUrl("http://www.purolator.com/purolator/ship-track/tracking-summary.page?submit=true&componentID=1359477580240");
            // wait 5 seconds
            driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
            // write page
            using (Stream stream = File.Open(@"d:\delete\selenium\1.html", FileMode.Create, FileAccess.ReadWrite))
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    byte[] bytes = Encoding.UTF8.GetBytes(driver.PageSource);
                    stream.Write(bytes, 0, bytes.Length);
                }
            }

            Console.WriteLine("Page title: " + driver.Title);
            // enter tracking number and submit
            IWebElement element = driver.FindElement(By.CssSelector("form textarea#search"));

            element.SendKeys("JFV242486848");
            element.Submit();
            //// wait 5 seconds
            //driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
            //// write result page
            //using (Stream stream = File.Open(@"d:\delete\selenium\2.html", FileMode.Create, FileAccess.ReadWrite))
            //{
            //    using (BinaryWriter writer = new BinaryWriter(stream))
            //    {
            //        byte[] bytes = Encoding.UTF8.GetBytes(driver.PageSource);
            //        stream.Write(bytes, 0, bytes.Length);
            //    }
            //}



            // locate the tracking history table
            var    trackingHistory = driver.FindElement(By.CssSelector("#historyDiv table#history tbody"));
            string result          = trackingHistory.Text;
            var    rows            = trackingHistory.FindElements(By.TagName("tr")).ToList();
            string locationPath    = "//td[@class='location']";
            //var locations = driverWait.Until(drv => drv.FindElements(By.XPath("//td[@class='location']")));
            //driverWait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//td[@class='location']")));
            var locations = driver.FindElements(By.XPath(locationPath));

            foreach (var location in locations)
            {
                string a = location.Text;
            }
            foreach (var row in rows)
            {
                var    t          = row.FindElements(By.TagName("td"));
                string location   = row.FindElements(By.ClassName("location")).FirstOrDefault().Text;
                string event_name = row.FindElements(By.TagName("td"))[3].Text;
            }
            // quit the driver
            driver.Quit();
        }
Exemplo n.º 59
0
 public TextFieldSeCollection(IWebElement webElement, By by)
     : base(webElement, by)
 {
 }
Exemplo n.º 60
0
 public static string GetInnerHtml(this IWebElement webElement)
 {
     return(webElement.GetAttribute("innerHTML"));
 }