public static void EnterText(IWebDriver driver, string element, string value, string elementtype) { if (elementtype == "Id") driver.FindElement(By.Id(element)).SendKeys(value); if (elementtype == "Name") driver.FindElement(By.Name(element)).SendKeys(value); }
public static bool FillOutLoginForm(IWebDriver driver, string username, string password, IWebElement submitButton = null, IWebElement usernameField = null, IWebElement passwordField = null) { try { if (usernameField == null && driver.FindElements(By.XPath(txtUsernameXPath)).Count > 0) usernameField = driver.FindElement(By.XPath(txtUsernameXPath)); if (passwordField == null && driver.FindElements(By.XPath(txtPasswordXPath)).Count > 0) passwordField = driver.FindElement(By.XPath(txtPasswordXPath)); if (submitButton == null && driver.FindElements(By.XPath(btnSubmitXPath)).Count > 0) submitButton = driver.FindElement(By.XPath(btnSubmitXPath)); if (usernameField != null && passwordField != null && submitButton != null) { usernameField.SendKeys(username); passwordField.SendKeys(password); submitButton.SendKeys(Keys.Enter); return true; } return false; } catch (IllegalLocatorException e) { return false; } }
//Selecting a drop down control public static void SelectDropDown(IWebDriver driver, string element, string value, string elementtype) { if (elementtype == "Id") new SelectElement(driver.FindElement(By.Id(element))).SelectByText(value); if (elementtype == "Name") new SelectElement(driver.FindElement(By.Name(element))).SelectByText(value); }
public GoogleSearch(IWebDriver driver, string p1, string p2) { try { driver.Navigate().GoToUrl("http://www.google.pt"); driver.FindElement(By.Name("q")).SendKeys(p1); Logger.Out("Driver title before send keys enter =" + driver.Title); //get the suggestions box from google Logger.Out(DateTime.Now.ToString()); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); wait.Until((d) => { return d.FindElement(By.ClassName("gssb_e")).Displayed; }); IWebElement resultsDiv = driver.FindElement(By.ClassName("gssb_e")); Logger.Out(DateTime.Now.ToString()); //// If results have been returned, the results are displayed in a drop down. if (resultsDiv.Displayed) { Logger.Out("Suggestions appeared"); } else throw new Exception("No suggestions"); driver.FindElement(By.Name("q")).SendKeys(Keys.Enter); Logger.Out("before wait"+driver.Title); wait.Until((d) => { return d.Title.StartsWith("banana"); }); //Check that the Title is what we are expecting Assert.AreEqual(p1+" - Pesquisa do Google", driver.Title); Logger.Out("after wait & assert- "+driver.Title); } catch (Exception ex) { throw ex; } }
public void PasswordlessAuthentication() { string email = "admin@test"; _webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome()); _webDriver.Manage().Window.Maximize(); _webDriver.Navigate().GoToUrl("http://dev.icms/Account/Login"); //Enter email address on login page IWebElement emailLogin = _webDriver.FindElement(By.Id("Email")); emailLogin.Clear(); emailLogin.SendKeys(email); IWebElement authenticateButton = _webDriver.FindElement(By.Id("requestauth")); authenticateButton.Click(); //this should have sent me an email //Let's pretend we got the email and check the server for the authtoken and plug it into the URL string token = HttpUtility.UrlEncode(TestUtilities.AuthenticationUtil.GetAuthToken(email)); string goToUrl = string.Format("http://dev.icms/account/authorize/?authtoken={0}&email={1}&returnUrl=%2f", token, email); _webDriver.Quit(); _webDriver = new RemoteWebDriver(new Uri("http://localhost:9515"), DesiredCapabilities.Chrome()); _webDriver.Navigate().GoToUrl(goToUrl); //Check DOM to see if we are logged in IWebElement elem = _webDriver.FindElement(By.CssSelector("h1")); Assert.IsTrue(elem.Text == "Welcome Admin Development"); }
private static void ButtonClickTest(IWebDriver driver) { driver.Url = "http://www.wikipedia.org"; IWebElement searchInput = driver.FindElement(By.Id("searchInput")); searchInput.SendKeys("Main Page"); IWebElement searchForm = driver.FindElement(By.Id("search-form")); searchForm.Submit(); //find the span for 'From today's featured article' IWebElement todayFeatureArticleBanner = driver.FindElement(By.Id("From_today.27s_featured_article")); //then go up to find the tr element containing the span IWebElement todayFeatureArticleBannerRow = todayFeatureArticleBanner.FindElement(By.XPath("../../..")); //then find its first tr slibing IWebElement todayFeatureArticleRow = todayFeatureArticleBannerRow.FindElement(By.XPath("following-sibling::tr[1]")); //then find the first bolded italic link at any level, // is for looping through all children IWebElement todayFeatureArticleLink = todayFeatureArticleRow.FindElement(By.XPath("//i/b/a")); Debug.WriteLine(String.Format("Today's Featured Article is \"{0}\", which is listed under the following categories:", todayFeatureArticleLink.Text)); todayFeatureArticleLink.Click(); //find an element with id catlinks var categoryLinksDiv = driver.FindElement(By.Id("catlinks")); //find all elements under the element with a div/ul/li path var categoryLinksLis = categoryLinksDiv.FindElements(By.XPath("div/ul/li")); foreach (var category in categoryLinksLis) { Debug.WriteLine(category.Text); } }
public void Batchpay(IWebDriver driver, string url, Datarow datarow) { // Payment for Physioroom if (url.Contains("physioroom") || url.Contains("trueshopping")) { driver.FindElement(By.XPath("//*[@id='ctl00']/section/fieldset/div[1]/label/span")).Click(); Thread.Sleep(2000); driver.FindElement(By.Id("Pagecontent_ButtonCheckoutStep3")).Click(); driver.Navigate().Back(); driver.FindElement(By.XPath("//*[@id='ctl00']/section/fieldset/div[2]/label/span")).Click(); Thread.Sleep(2000); driver.FindElement(By.Id("Pagecontent_ButtonCheckoutStep3")).Click(); datarow.Newrow("", "", "Mopay", "", driver); var mopay = new MopayTps(); mopay.Mopay(driver, datarow); } else { // This is a general payment testing using Mopay and needs to be extended if the client offering more than one payment process for example Paypal. datarow.Newrow("", "", "Mopay", "", driver); var mopay = new MopayTps(); mopay.Mopay(driver, datarow); } }
// Click to element public static void ClickElement(IWebDriver driver, string element, string elementType) { if (elementType == "id") driver.FindElement(By.Id(element)).Click(); if (elementType == "XPath") driver.FindElement(By.XPath(element)).Click(); }
public void TheXTest() { driver = new FirefoxDriver(); IJavaScriptExecutor js = driver as IJavaScriptExecutor; Login u = new Login(driver); string login1 = "guest"; u.get().login(login1, login1).click();//Š²Ń Š¾Š“ Š½Š° ŃŠ°Š¹Ń driver.FindElement(By.Id("sovzond_widget_SimpleButton_104")).Click(); Thread.Sleep(5000); IWebElement element = driver.FindElement(By.Id("sovzond_widget_SimpleButton_0")); var builder = new Actions(driver); builder.Click(element).Perform(); IList<IWebElement> el = driver.FindElements(By.ClassName("svzLayerManagerItem")); for (int n = 0; n < el.Count; n++) { if (el[0].Text != "Google") Assert.Fail("Š½Šµ Š½Š°Š¹Š“ŠµŠ½ Google"); if (el[4].Text != "Š Š¾ŃŃŠµŠµŃŃŃ") Assert.Fail("Š½Šµ Š½Š°Š¹Š“ŠµŠ½ Š Š¾ŃŃŠµŠµŃŃŃ"); if (el[5].Text != "OpenStreetMap") Assert.Fail("Š½Šµ Š½Š°Š¹Š“ŠµŠ½ OpenStreetMap"); if (el[6].Text != "Š¢Š¾ŠæŠ¾Š¾ŃŠ½Š¾Š²Š°") Assert.Fail("Š½Šµ Š½Š°Š¹Š“ŠµŠ½ Š¢Š¾ŠæŠ¾Š¾ŃŠ½Š¾Š²Š°"); } IWebElement element1 = driver.FindElement(By.Id("dijit_form_RadioButton_3")); builder.Click(element1).Perform(); Thread.Sleep(5000); string h= (string)js.ExecuteScript("return window.portal.stdmap.map.baseLayer.div.id.toString()"); }
//Select from dropdown public static void SelectDropDown(IWebDriver driver, string element, string value, string elementType) { if (elementType == "id") new SelectElement(driver.FindElement(By.Id(element))).SelectByText(value); if (elementType == "XPath") new SelectElement(driver.FindElement(By.XPath(element))).SelectByText(value); }
public void PopulateProjectNameWithSpecialChar(IWebDriver driverInstance) { IWebElement input = driverInstance.FindElement(NgBy.Input("ProjectWizardController.project.name")); input.Clear(); input.SendKeys("##TEST##"); driverInstance.FindElement(By.Id("txtDescription")).Click(); }
public void WhereIsMyCheese(string url) { try { _driver = Browser.GetFirefoxDriver(); _driver.Navigate().GoToUrl(url); _driver.FindElement(By.Id("windowOpener")).Click(); _driver.SwitchTo().Window("windowName"); _driver.FindElement(By.Id("CheesyButton")).Click(); _driver.SwitchTo().Alert().Accept(); } catch (System.Exception ex) { Console.WriteLine("An exception occured: " + ex.Message); Debug.WriteLine("An exception occured: " + ex.Message); } finally { _driver.Quit(); } }
private static void AssetSelection(IWebDriver driver) { for (var n = 0; n <= 1; n++) { driver.FindElement(By.CssSelector("img.img-responsive.center-block")).Click(); driver.FindElement(By.Id("s2id_autogen1")).Click(); var groups = new SelectElement(driver.FindElement(By.Id("groups"))); groups.SelectByIndex(n); var assetType = groups.SelectedOption.Text; driver.FindElement(By.CssSelector("button.btn.gradient")).Click(); //click search //Groups dropdown IList<IWebElement> details = driver.FindElements(By.LinkText("Details")); Console.WriteLine("There are {0} {1} ", details.Count(), assetType); NavigateGroups(driver, details); // driver.FindElement(By.CssSelector("img.img-responsive.center-block")).Click(); // driver.FindElement(By.CssSelector("a.select2-search-choice-close")).Click(); //clear } //Console.ReadKey(); }
public void Case001_Login() { // InternetExplorerOptions options = new InternetExplorerOptions(); // options.IgnoreZoomLevel = true; driver = new ChromeDriver(); driver.Navigate().GoToUrl("http://sheltered-stream-7018.herokuapp.com/"); IWebElement testLogin = driver.FindElement(By.ClassName("login_button")); testLogin.Click(); IWebElement enterLogin = driver.FindElement(By.Id("username_or_email")); enterLogin.SendKeys("azimuth_user_1"); enterLogin = driver.FindElement(By.Id("password")); enterLogin.SendKeys("whiskey"); IWebElement testAuthorize = driver.FindElement(By.Id("allow")); testAuthorize.Click(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(4)); IWebElement findH2 = driver.FindElement(By.TagName("h2")); string doesTitleExist = findH2.Text; System.Console.WriteLine(doesTitleExist); Assert.AreEqual(doesTitleExist,"Profile"); }
public void Dsecure(IWebDriver driver) { var frameElement = driver.FindElement(By.TagName("iframe")); driver.SwitchTo().Frame(frameElement); driver.FindElement(By.CssSelector("input[type=\"submit\"]")).Click(); Thread.Sleep(0x1388); Thread.Sleep(0x1f40); var location = driver.Url; if (location.Contains("3DSecureState=Success")) { _datarow.Newrow("3D secure", location, "3DSecureState=Success", "PASS", driver); if (IsElementPresent(driver, By.LinkText("start again"))) { driver.FindElement(By.LinkText("start again")).Click(); } else { driver.Navigate().GoToUrl("http://devpaytest.mobankdev.com/"); } } else { _datarow.Newrow("3D secure", location, "3D secure Declined", "FAIL", driver); if (IsElementPresent(driver, By.LinkText("start again"))) { driver.FindElement(By.LinkText("start again")).Click(); } else { driver.Navigate().GoToUrl("http://devpaytest.mobankdev.com/"); } } }
private static void ExecuteScript(IWebDriver wd) { try { //wd.Manage().Window.Maximize(); //Console.WriteLine("Browser Maximizado"); wd.Navigate().GoToUrl("http://www.minhaseconomias.com.br"); Console.WriteLine("Acessado o Site Minhas Economias"); wd.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); wd.FindElement(By.ClassName("login")).Click(); wd.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); Console.WriteLine("Clicado no BotĆ£o de 'Entrar'"); wd.FindElement(By.Id("email")).SendKeys("*****@*****.**"); Console.WriteLine("Digitado o Login (E-mail)"); wd.FindElement(By.Id("senha")).SendKeys("abc@123"); Console.WriteLine("Digitada a Senha"); wd.FindElement(By.Id("login")).FindElement(By.Name("OK")).Click(); Console.WriteLine("Clicado no botĆ£o 'Entrar'"); } finally { wd.Close(); } }
public void Cookie(IWebDriver driver, Datarow datrow) { try { //cookie Disclosure IsElementPresent(driver, By.CssSelector("div.cookieDisclosure")); var disclosuretext = driver.FindElement(By.CssSelector("div.cookieDisclosure")).Text; datrow.Newrow("Diclosure Text is Presnt", "This site uses cookies. Some of the cookies we use are essential for parts of the site to operate and have already been set.", disclosuretext, disclosuretext == "This site uses cookies. Some of the cookies we use are essential for parts of the site to operate and have already been set." ? "PASS" : "FAIL"); if (IsElementPresent(driver, By.Id("epdsubmit"))) { driver.FindElement(By.Id("epdsubmit")).Click(); datrow.Newrow("Validating 'OK' Button in cookie disclosure ", "OK button is present", "OK button is present", "PASS"); } else { datrow.Newrow("Validating 'OK' Button in cookie disclosure ", "OK button is present", "OK button is not present", "FAIL"); } } catch (Exception ex) { var e = ex.ToString(); datrow.Newrow("Exception Not Expceted", "Not Expected", e, "FAIL"); } }
// Click into checkbox public static void Click(IWebDriver driver, string element, string value, string elementtype) { if (elementtype == "Id") driver.FindElement(By.Id(element)).Click(); if (elementtype == "Name") driver.FindElement(By.Name(element)).Click(); }
public void PopulateEmptyProjectName(IWebDriver driverInstance) { IWebElement input = driverInstance.FindElement(NgBy.Input("ProjectWizardController.project.name")); input.Clear(); //input.SendKeys("1"); driverInstance.FindElement(By.Id("txtDescription")).Click(); }
public void Dsecure(IWebDriver driver) { if (IsElementPresent(driver, By.TagName("iframe"))) { var frameElement = driver.FindElement(By.TagName("iframe")); driver.SwitchTo().Frame(frameElement); driver.FindElement(By.CssSelector("input[type=\"submit\"]")).Click(); Thread.Sleep(0x1388); driver.SwitchTo().Alert().Accept(); var location = driver.Url; if (location.Contains("3DSecureState=Success")) { _datarow.Newrow("3D secure", location, "3DSecureState=Success", "PASS", driver); driver.FindElement(By.LinkText("start again")).Click(); } else if (location.Contains("State=Declined")) { _datarow.Newrow("3D secure", location, "3D secure Declined", "FAIL", driver); driver.FindElement(By.LinkText("start again")).Click(); } } else { var actual = driver.Url; _datarow.Newrow("Checkout", "Server Error", actual, "FAIL", driver); new Screenshot().Screenshotfailed(driver); driver.Navigate().GoToUrl("http://devpaytest.mobankdev.com/"); } }
public void Login() { driver = new InternetExplorerDriver(); try { //Run before any test driver.Navigate().GoToUrl(url + "MDM"); driver.FindElement(By.Id("userNameTextBox")).SendKeys(user); driver.FindElement(By.Id("passwordTextBox")).SendKeys(password); driver.FindElement(By.Id("loginBtn")).Click(); Common.WaitForElement(driver, By.ClassName("breadcrumbs"), 30); } catch (TimeoutException e) { System.Console.WriteLine("TimeoutException: " + e.Message); Assert.Fail(e.Message); } catch (NoSuchElementException e) { Assert.Fail(e.Message); } catch (Exception e) { System.Console.WriteLine("unhandled exception: " + e.Message); Assert.Fail(e.Message); } }
public void Runscrape(IWebDriver driver, Datarow datarow) { try { driver.FindElement(By.LinkText("Execute")).Click(); try { Selectanoption(driver, By.Id("TestCatalogueId"), "testshop (Default)"); } catch (Exception) { Selectanoption(driver, By.Id("TestCatalogueId"), "testshop (0.1)"); } //new SelectElement(driver.FindElement(By.Id("TestCatalogueId"))).SelectByText("Default"); driver.FindElement(By.Name("PostAction[]")).Click(); var title = driver.Title; Scarperead(driver, datarow, title); } catch (Exception ex) { var e = ex.ToString(); datarow.Newrow("Exception", "Excepion Not Expected", e, "FAIL", driver); } }
//å²čå¢é”µé¢ååēØę·ē»å½ public static void betaShopLogin(string userName, string password, IWebDriver driver) { driver.FindElement(By.LinkText("ēØę·ē»å½")).Click(); driver.webDriverWait(By.Id("userName"), 5).SendKeys(userName); driver.FindElement(By.Id("password")).SendKeys(password); driver.FindElement(By.Id("identifyingCode")).SendKeys("1111"); driver.FindElement(By.Id("submitlog")).Click(); }
public void Setup() { driver = new ChromeDriver(@"C:\ChromeDriver\"); driver.Navigate().GoToUrl("http://component-showcase.icesoft.org/component-showcase/showcase.iface"); driver.FindElement(By.LinkText("Table")).Click(); driver.FindElement(By.LinkText("Row Selection")).Click(); driver.FindElement(By.XPath("//label[contains(text(),'Multiple')]")).Click(); }
private void LogOn() { driver = new FirefoxDriver(); driver.Navigate().GoToUrl("http://91.143.44.249/sovzond/portal/login.aspx?ReturnUrl=%2fsovzond%2fportal"); driver.FindElement(By.Id("txtUser")).SendKeys("guest"); driver.FindElement(By.Id("txtPsw")).SendKeys("guest"); driver.FindElement(By.Id("cmdLogin")).Click(); }
public void Login(IWebDriver driverToUse) { driverToUse.FindElement(By.Id("login_UserName")).Clear(); driverToUse.FindElement(By.Id("login_UserName")).SendKeys("Admin"); driverToUse.FindElement(By.Id("login_Password")).Clear(); driverToUse.FindElement(By.Id("login_Password")).SendKeys("testing"); driverToUse.FindElement(By.Id("login_LoginButton")).Click(); }
private void LogIn() { driver = new FirefoxDriver(); driver.Navigate().GoToUrl(baseUrl); driver.FindElement(By.Id("txtUser")).SendKeys("guest"); driver.FindElement(By.Id("txtPsw")).SendKeys("guest"); driver.FindElement(By.Id("cmdLogin")).Click(); }
public void Like() { //find like button var likeBtn = webDriver?.FindElement(By.XPath(ElementIdentify.likeXpath)); //TODO: check isLike likeBtn?.Click(); }
public void LoginWithValidCredentials() { driver = new FirefoxDriver(); driver.Url = "http://localhost/php4dvd"; driver.FindElement(By.Name("username")).SendKeys("admin"); driver.FindElement(By.Name("password")).SendKeys("admin"); driver.FindElement(By.CssSelector("input[type=submit]")).Click(); }
public string Option(IWebDriver driver, By by, int timeoutseconds = 10) { var data = driver.FindElement(by); //IList<IWebElement> dataoptions = data.FindElements(By.TagName("option")); new SelectElement(data); var option = driver.FindElement(By.TagName("option")).GetAttribute("Value"); var optio = driver.FindElement(By.TagName("option")).Text; return option; }
public void Login() { _driver = new FirefoxDriver(); _driver.Url = "https://login.yahoo.com/config/mail?&.src=ym&.intl=uk"; _driver.FindElement(By.Id("login-username")).SendKeys("sudeepthi.mogalapalli"); _driver.FindElement(By.Id("login-passwd")).SendKeys("SudeeAdi2712"); _driver.FindElement(By.Id("login-signin")).Click(); Thread.Sleep(4000); }
internal static IWebElement FindPageElements(By by) { return(_webDriver.FindElement(by)); }
public void TheCP2CrearCuentaFBFirefoxTest() { try { //Alta de usuario en el Web Administrator-------------------------- string[] parametros = LeerCSV("C:\\Users\\ADMDBQA.user\\Documents\\CP2_configuracion.txt"); driver.Navigate().GoToUrl(baseURL); Thread.Sleep(5000); driver.FindElement(By.CssSelector("#form > div.create-account > p > a")).Click(); driver.FindElement(By.Id("customBtnFB")).Click(); // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | win_ser_3 | ]] driver.SwitchTo().Window(driver.WindowHandles.Last()); driver.FindElement(By.Id("email")).Click(); // ERROR: Caught exception [ERROR: Unsupported command [doubleClick | id=email | ]] driver.FindElement(By.Id("email")).SendKeys(parametros[0]); driver.FindElement(By.Id("buttons")).Click(); driver.FindElement(By.Id("pass")).Click(); driver.FindElement(By.Id("pass")).Clear(); driver.FindElement(By.Id("pass")).SendKeys(parametros[1]); driver.FindElement(By.CssSelector("input[value='Log In']")).Click(); //ERROR: Caught exception[ERROR: Unsupported command[selectWindow | win_ser_local | ]] Thread.Sleep(3000); driver.SwitchTo().Window(driver.WindowHandles.FirstOrDefault()); Thread.Sleep(3000); driver.FindElement(By.Id("FirstName")).Click(); //ERROR: Caught exception[ERROR: Unsupported command[dragAndDropToObject | id = FirstName | id = LastName]] driver.FindElement(By.Id("LastName")).Click(); driver.FindElement(By.Id("LastName")).Clear(); driver.FindElement(By.Id("LastName")).SendKeys(parametros[2]); Thread.Sleep(3000); driver.FindElement(By.Id("Email")).Click(); driver.FindElement(By.Id("Email")).Clear(); driver.FindElement(By.Id("Email")).SendKeys(parametros[0]); Thread.Sleep(3000); driver.FindElement(By.Id("Password")).Click(); driver.FindElement(By.Id("Password")).Clear(); driver.FindElement(By.Id("Password")).SendKeys(parametros[3] + Keys.Tab); Thread.Sleep(3000); driver.FindElement(By.Id("ConfirmPassword")).Click(); driver.FindElement(By.Id("ConfirmPassword")).Clear(); driver.FindElement(By.Id("ConfirmPassword")).SendKeys(parametros[3]); //// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | index=0 | ]] //driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='reCAPTCHA'])[1]/preceding::div[4]")).Click(); //// ERROR: Caught exception [ERROR: Unsupported command [selectFrame | relative=parent | ]] Thread.Sleep(2000); driver.FindElement(By.Id("registerbtn")).Click(); } catch (Exception e) { Assert.Fail(e.Message); } }
/// <summary> /// Sets web driver and login and password web elements /// </summary> /// <param name="webDriver">Web driver used by page object</param> public LoginPage(IWebDriver webDriver) : base(webDriver) { loginBar = webDriver.FindElement(_loginBarLocator); passwordBar = webDriver.FindElement(_passwordBarLocator); }
public void Goro() { IWebElement Tommorow = driver.FindElement(By.XPath("//a[contains(text(),'ŠŠ¾ŃŠ¾ŃŠŗŠ¾Šæ Š½Š° Š·Š°Š²ŃŃŠ°')]")); Assert.IsTrue(Tommorow.Displayed); }
public void TestCase1() { //Find page Element and input value IWebElement element = driver.FindElement(By.Id("position")); element.SendKeys("4"); //Click Button IWebElement submit_button = driver.FindElement(By.Id("reveal")); submit_button.Click(); //Verify Result IWebElement ActualResult = driver.FindElement(By.Id("answer2")); String StringResult = ActualResult.Text; String ExpectedResult = "3"; Assert.AreEqual(StringResult, ExpectedResult); //Assert.AreEqual(ActualResult.Text, "3"); //Delete typed input or Refresh element.Clear(); }
public void TestConceptualPage() { _driver.Navigate().GoToUrl(_urlHomepage); TestPageCommon(); // check "Improve this Doc" button FindAndTestLinkTitle(_driver, "Improve this Doc", "GitHub"); // check heading 2 and sidebar IList <IWebElement> resultsHeading = _driver.FindElements(By.TagName("h2")); if (resultsHeading.Count > 0) { IList <IWebElement> resultsSidebar = _driver.FindElements(By.XPath("//nav[@id='affix']/ul/li/a")); Assert.Equal(resultsHeading.Count, resultsSidebar.Count); for (int i = 0; i < resultsSidebar.Count; i++) { Assert.Equal(resultsHeading[i].Text, resultsSidebar[i].Text); var id = resultsHeading[i].GetAttribute("id"); var href = resultsSidebar[i].GetAttribute("href"); Assert.Equal(id, href.Substring(href.Length - id.Length)); } } // check heading 3 and sidebar resultsHeading = _driver.FindElements(By.TagName("h3")); if (resultsHeading.Count > 0) { IList <IWebElement> resultsSidebar = _driver.FindElements(By.XPath("//nav[@id='affix']/ul/li/ul/li/a")); Assert.Equal(resultsHeading.Count, resultsSidebar.Count); for (int i = 0; i < resultsSidebar.Count; i++) { var id = resultsHeading[i].GetAttribute("id"); var href = resultsSidebar[i].GetAttribute("href"); Assert.Equal(id, href.Substring(href.Length - id.Length)); } } // check footer Assert.NotEmpty(_driver.FindElements(By.XPath("//footer/div[@class='footer']/div[@class='container']"))); // check breadcrumb Assert.NotEmpty(_driver.FindElements(By.XPath("//div[@id='breadcrumb']/ul/li/a"))); // go to 'Articles' _driver.FindElement(By.XPath("//div[@id='navbar']/ul/li/a[@title='Articles']")).Click(); // check toc IList <IWebElement> results = _driver.FindElements(By.XPath("//div[@class='sidetoc']/div[@id='toc']/ul/li")); Assert.NotEmpty(results); Assert.Equal("Getting Started", _driver.FindElement(By.XPath("//div[@class='sidetoc']/div[@id='toc']/ul/li[@class='active in']/a")).Text); var title = results[results.Count - 1].Text; // check filter _driver.FindElement(By.Id("toc_filter_input")).SendKeys(title); Assert.True(results[results.Count - 1].Displayed); results[results.Count - 1].Click(); results = _driver.FindElements(By.XPath("//div[@id='toc']/ul/li")); Assert.NotEmpty(results); Assert.Equal("active in", results[results.Count - 1].GetAttribute("class")); }
public string FTP_CASantaBarbara(string houseno, string sname, string sttype, string parcelNumber, string unitnumber, string searchType, string orderNumber, string ownername, string directParcel) { GlobalClass.global_orderNo = orderNumber; HttpContext.Current.Session["orderNo"] = orderNumber; GlobalClass.global_parcelNo = parcelNumber; string StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = ""; var driverService = PhantomJSDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = true; // driver = new PhantomJSDriver(); // driver = new ChromeDriver(); using (driver = new PhantomJSDriver()) { try { StartTime = DateTime.Now.ToString("HH:mm:ss"); if (searchType == "titleflex") { gc.TitleFlexSearch(orderNumber, parcelNumber, ownername, "", "CA", "Santa Barbara"); if (HttpContext.Current.Session["titleparcel"] != null && ownername.Trim() != "") { string[] strowner = ownername.Split(' '); gc.TitleFlexSearch(orderNumber, parcelNumber, strowner[0], "", "CA", "Santa Barbara"); } if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes")) { driver.Quit(); return("MultiParcel"); } else if (HttpContext.Current.Session["titleparcel"].ToString() == "") { HttpContext.Current.Session["Nodata_CASantaBarbara"] = "Zero"; driver.Quit(); return("No Data Found"); } searchType = "parcel"; parcelNumber = HttpContext.Current.Session["titleparcel"].ToString(); } if (searchType == "address") { driver.Navigate().GoToUrl("http://www.sbcvote.com/assessor/search.aspx"); Thread.Sleep(2000); driver.FindElement(By.Id("HouseNumberTextBox")).SendKeys(houseno); driver.FindElement(By.Id("StreetNameTextBox")).SendKeys(sname); driver.FindElement(By.Id("UnitNumberTextBox")).SendKeys(unitnumber); //Screen-Shot gc.CreatePdf_WOP(orderNumber, "AddressSearch", driver, "CA", "Santa Barbara"); driver.FindElement(By.Id("SearchButton")).SendKeys(Keys.Enter); Thread.Sleep(2000); //MultiParcel try { IWebElement MultiParcelTable = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table")); IList <IWebElement> MultiParcelTR = MultiParcelTable.FindElements(By.TagName("tr")); IList <IWebElement> MultiParcelTD; foreach (IWebElement multi in MultiParcelTR) { MultiParcelTD = multi.FindElements(By.TagName("td")); if (multi.Text.Contains("Assessor Parcel Number (APN)")) { strAssess = "MultiParcel"; } if (MultiParcelTD.Count != 0 && strAssess.Trim() == "MultiParcel" && !multi.Text.Contains("Assessor Parcel Number (APN)") && MultiParcelTD.Count != 1 && MultiParcelTD[1].Text != "") { HttpContext.Current.Session["multiParcel_CASantaBarbara"] = "Yes"; parcelNumber = MultiParcelTD[1].Text; Situs_Address = MultiParcelTD[2].Text; MultiParcelData = Situs_Address; gc.insert_date(orderNumber, parcelNumber, 220, MultiParcelData, 1, DateTime.Now); } } if (strAssess == "MultiParcel") { driver.Quit(); return("MultiParcel"); } } catch { } } if (searchType == "parcel") { driver.Navigate().GoToUrl("http://www.sbcvote.com/assessor/search.aspx"); Thread.Sleep(2000); driver.FindElement(By.Id("APNTextBox")).SendKeys(parcelNumber); gc.CreatePdf(orderNumber, parcelNumber, "ParcelSearch", driver, "CA", "Santa Barbara"); driver.FindElement(By.Id("SearchButton")).SendKeys(Keys.Enter); Thread.Sleep(2000); } try { IWebElement Inodata = driver.FindElement(By.Id("ErrorLabel")); if (Inodata.Text.Contains("There were no properties matching your query")) { HttpContext.Current.Session["Nodata_CASantaBarbara"] = "Zero"; driver.Quit(); return("No Data Found"); } } catch { } //Scrapped Data //Property Deatails string propdet = driver.FindElement(By.XPath("//*[@id='form1']/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[2]/td/table/tbody")).Text.Replace("\r\n", " "); outparcelno = gc.Between(propdet, "Parcel Number:", "Address:").Trim().Replace("Value Notice", ""); outparcelnowoh = outparcelno.Replace("-", "").Trim(); Street_Address = gc.Between(propdet, "Address:", "Transfer Date:").Trim().Replace("Value Notice", ""); TRA = gc.Between(propdet, "TRA:", "Document").Trim(); Transfer_TaxAmount = GlobalClass.After(propdet, "Transfer Tax Amount:").Trim(); string propdet1 = driver.FindElement(By.XPath("//*[@id='form1']/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[3]/td/table")).Text.Replace("\r\n", " "); Use_Description = gc.Between(propdet1, "Use Description:", "Jurisdiction:").Trim(); Jurisdiction = gc.Between(propdet1, "Jurisdiction:", "Acreage:").Trim(); Acreage = gc.Between(propdet1, "Acreage:", "Square Feet:").Trim(); Year_Built = gc.Between(propdet1, "Year Built:", "Bedrooms:").Trim(); gc.CreatePdf(orderNumber, outparcelnowoh, "Assement", driver, "CA", "Santa Barbara"); property_Address = Street_Address + "~" + TRA + "~" + Transfer_TaxAmount + "~" + Use_Description + "~" + Jurisdiction + "~" + Acreage + "~" + Year_Built; gc.insert_date(orderNumber, outparcelno, 221, property_Address, 1, DateTime.Now); //Assessment Details Land_MineralRights = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[6]/td/table/tbody/tr[2]/td[3]")).Text; Improvements = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[6]/td/table/tbody/tr[4]/td[3]")).Text; Personal_Property = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[6]/td/table/tbody/tr[6]/td[3]")).Text; Home_OwnerExemption = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[6]/td/table/tbody/tr[8]/td[3]")).Text; Other_Exemption = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[6]/td/table/tbody/tr[10]/td[3]")).Text; Net_AssessedValue = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[6]/td/table/tbody/tr[12]/td[3]")).Text; assement_details = Land_MineralRights + "~" + Improvements + "~" + Personal_Property + "~" + Home_OwnerExemption + "~" + Other_Exemption + "~" + Net_AssessedValue; gc.insert_date(orderNumber, outparcelno, 222, assement_details, 1, DateTime.Now); AssessmentTime = DateTime.Now.ToString("HH:mm:ss"); //Download the pdf for Tax Details String Parent_Window = driver.CurrentWindowHandle; string cururl = driver.Url; //Value_Notice IWebElement ValueNotice = driver.FindElement(By.XPath("/html/body/form/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/table/tbody/tr[3]/td[2]/table/tbody/tr[5]/td/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3]/table/tbody/tr/td[2]/span/strong/a")); IJavaScriptExecutor js1 = driver as IJavaScriptExecutor; js1.ExecuteScript("arguments[0].click();", ValueNotice); Thread.Sleep(2000); System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; driver.SwitchTo().Window(driver.WindowHandles.Last()); Thread.Sleep(2000); gc.CreatePdf(orderNumber, outparcelnowoh, "Value_Tax.pdf", driver, "CA", "Santa Barbara"); // driver.SwitchTo().Window(Parent_Window); driver.Navigate().GoToUrl(cururl); Thread.Sleep(2000); //Jurisdiction Details try { taxUrl = driver.FindElement(By.XPath("//*[@id='lblAuditorLink']/a")).GetAttribute("href").ToString(); driver.Navigate().GoToUrl(taxUrl); IWebElement SelectOption = driver.FindElement(By.Id("Criteria#001")); IList <IWebElement> Select = SelectOption.FindElements(By.TagName("option")); List <string> option = new List <string>(); string opt = ""; int Check = 0; foreach (IWebElement Op in Select) { if (Check == 1) { //option.Add(Op.Text); opt = Op.Text; break; } Check++; } //foreach (string item in option) //{ var SelectAddress = driver.FindElement(By.Id("Criteria#001")); var SelectAddressTax = new SelectElement(SelectAddress); SelectAddressTax.SelectByText(opt); driver.FindElement(By.Name("Submit")).Click(); Thread.Sleep(2000); IWebElement asstable = driver.FindElement(By.XPath("/html/body/table[5]/tbody/tr/td[2]/table[1]/tbody/tr[2]/td[2]/h1/table[1]/tbody")); IList <IWebElement> asstr = asstable.FindElements(By.TagName("tr")); IList <IWebElement> asstd; foreach (IWebElement tax in asstr) { asstd = tax.FindElements(By.TagName("td")); if (asstd.Count != 0 && asstd.Count == 5 && tax.Text.Trim() != "" && !tax.Text.Contains("Parcel Number") || (tax.Text.Contains("Basic") || tax.Text.Contains("Total") || tax.Text.Contains("Fixed") || tax.Text.Contains("Situs"))) { Taxrate_Area = asstd[2].Text.Trim(); NetAssessed_Value = asstd[4].Text.Trim(); } } gc.CreatePdf(orderNumber, outparcelnowoh, "Property_Tax.pdf", driver, "CA", "Santa Barbara"); NoteTax = Taxrate_Area + "~" + NetAssessed_Value + "~" + "-" + "~" + "-"; gc.insert_date(orderNumber, outparcelno, 239, NoteTax, 1, DateTime.Now); //} IWebElement TBTax = driver.FindElement(By.XPath("/html/body/table[5]/tbody/tr/td[2]/table[1]/tbody/tr[2]/td[2]/h1/table[2]/tbody")); IList <IWebElement> TRTax = TBTax.FindElements(By.TagName("tr")); IList <IWebElement> TDTax; foreach (IWebElement tax in TRTax) { TDTax = tax.FindElements(By.TagName("td")); if (TDTax.Count != 0 && TDTax.Count != 1 && tax.Text.Trim() != "" && !tax.Text.Contains("Fund") || (tax.Text.Contains("Basic") || tax.Text.Contains("Total") || tax.Text.Contains("Fixed") || tax.Text.Contains("Bonds") || tax.Text.Contains("9801 - County School Srvc Fund"))) { try { Fund = TDTax[0].Text; Amount = TDTax[2].Text; } catch { Amount = "-"; } proprtyTax = "-" + "~" + "-" + "~" + Fund + "~" + Amount; gc.insert_date(orderNumber, parcelNumber, 239, proprtyTax, 1, DateTime.Now); } } } catch { } driver.Navigate().GoToUrl("https://Mytaxes.sbtaxes.org/WebPages/Assistance_ContactUs.aspx"); Thread.Sleep(2000); gc.CreatePdf(orderNumber, outparcelnowoh, "Current_Authority.pdf", driver, "CA", "Santa Barbara"); Tax_Authority = driver.FindElement(By.XPath("//*[@id='ctl00_PageContentBody_ASPxPageControl1_C0']/div/div[1]/div[2]/div/h4")).Text + " " + driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/div/div[2]/div[1]/div/div[1]/div/div[1]/div[2]/div/ul")).Text; //Tax Information driver.Navigate().GoToUrl("http://www.countyofsb.org/ttcpapg/index.aspx"); Thread.Sleep(2000); try { IWebElement TaxInfo = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div[2]/div/a")); IJavaScriptExecutor TI = driver as IJavaScriptExecutor; TI.ExecuteScript("arguments[0].click();", TaxInfo); Thread.Sleep(2000); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); var element = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("/html/body/form/div[3]/div[1]/div[2]/div[2]/div[1]/table/tbody/tr/td[2]"))); Actions action = new Actions(driver); action.MoveToElement(element).Perform(); Thread.Sleep(2000); driver.FindElement(By.XPath("/html/body/form/div[3]/div[1]/div[2]/div[2]/div[1]/table/tbody/tr/td[2]/div/div[2]/div/ul/li[1]/div/span")).Click(); Thread.Sleep(2000); driver.FindElement(By.Id("ctl00_ASPxCallbackPanel1_combo_Search_I")).SendKeys(outparcelno); gc.CreatePdf(orderNumber, outparcelnowoh, "City_Info.pdf", driver, "CA", "Santa Barbara"); driver.FindElement(By.Id("ctl00_ASPxCallbackPanel1_btn_Search")).Click(); Thread.Sleep(2000); gc.CreatePdf(orderNumber, outparcelnowoh, "City_Info_tax.pdf", driver, "CA", "Santa Barbara"); //Tax Bill //Download the pdf for Tax Details //String Parent_Window1 = driver.CurrentWindowHandle; //IWebElement taxbill = driver.FindElement(By.XPath("//*[@id='ctl00_PageContentBody_tabControl_Propertys_gridView_BillDetail_cell1_0_BillMenu_DXI0_T']")); //IJavaScriptExecutor TB = driver as IJavaScriptExecutor; //TB.ExecuteScript("arguments[0].click();", taxbill); //Thread.Sleep(2000); //System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //driver.SwitchTo().Window(driver.WindowHandles.Last()); //Thread.Sleep(4000); //gc.CreatePdf_Chrome(orderNumber, outparcelno, "Tax_Bill.pdf", driver, "CA", "Santa Barbara"); //driver.SwitchTo().Window(Parent_Window1); //Thread.Sleep(2000); } catch { } try { //Current Tax Details Property_Type = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/table/tbody/tr/td/table/tbody/tr[2]/td[2]")).Text; try { Current_PropertyAddress = driver.FindElement(By.Id("ctl00_PageContentBody_gridView_Propertys_cell0_2_ASPxSitusAddressLine1")).Text + " " + driver.FindElement(By.Id("ctl00_PageContentBody_gridView_Propertys_cell0_2_ASPxSitusAddressLine2")).Text; } catch { } Property_Remarks = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/table/tbody/tr/td/table/tbody/tr[2]/td[4]")).Text; TotalDue = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/table/tbody/tr/td/table/tbody/tr[2]/td[6]")).Text; gc.CreatePdf(orderNumber, outparcelnowoh, "Current_Tax.pdf", driver, "CA", "Santa Barbara"); Bill_Tax1 = Property_Type + "~" + Current_PropertyAddress + "~" + Property_Remarks + "~" + TotalDue + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-"; gc.insert_date(orderNumber, outparcelno, 242, Bill_Tax1, 1, DateTime.Now); IWebElement TBCurrnetTax = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/div[2]/div/div[1]/div/table/tbody/tr/td/table[2]/tbody")); IList <IWebElement> TRCurrnetTax = TBCurrnetTax.FindElements(By.TagName("tr")); IList <IWebElement> TDCurrnetTax; int i = 3; foreach (IWebElement CurrentTax in TRCurrnetTax) { TDCurrnetTax = CurrentTax.FindElements(By.TagName("td")); if (TDCurrnetTax.Count != 0 && !CurrentTax.Text.Contains("Bill Menu") && !CurrentTax.Text.Contains("Paid Bills") && !CurrentTax.Text.Contains("Date") && !CurrentTax.Text.Contains("Year") && !CurrentTax.Text.Contains("Property Address") && !CurrentTax.Text.Contains("First Installment") && !CurrentTax.Text.Contains("Second Installment") && CurrentTax.Text.Trim() != "") { Bill_No = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/div[2]/div/div[1]/div/table/tbody/tr/td/table[2]/tbody/tr[" + i + "]/td[2]/div")).Text; if (Bill_No.Contains("\r\n")) { Bill_No = Bill_No.Replace("\r\n", " "); } Bill_Date = TDCurrnetTax[2].Text; Bill_Year = TDCurrnetTax[3].Text; Bill_PropertyAddress = TDCurrnetTax[4].Text; Bill_FirstInstallment = TDCurrnetTax[5].Text; Bill_SecondInstallment = TDCurrnetTax[6].Text; Bill_Tax = "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + Bill_No + "~" + Bill_Date + "~" + Bill_Year + "~" + Bill_PropertyAddress + "~" + Bill_FirstInstallment + "~" + Bill_SecondInstallment + "~" + "-"; gc.insert_date(orderNumber, outparcelno, 242, Bill_Tax, 1, DateTime.Now); i++; } } try { IWebElement Ilink = driver.FindElement(By.Id("ctl00_PageContentBody_tabControl_Propertys_gridView_BillDetail_cell1_0_BillMenu_DXI0_T")); string strLink = "https://mytaxes.sbtaxes.org/WebPages/" + gc.Between(Ilink.GetAttribute("href"), "javascript: PopUpCenter('", "||"); gc.downloadfile(strLink, orderNumber, outparcelnowoh, "TaxBill.pdf", "CA", "Santa Barbara"); } catch { } // driver.Navigate().Back(); // Thread.Sleep(2000); } catch { } try { Taxauthority = "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + "-" + "~" + Tax_Authority; gc.insert_date(orderNumber, outparcelnowoh, 242, Taxauthority, 1, DateTime.Now); } catch { } try { //Taxes and Values Details string Ok = ""; IWebElement Tax_Value = driver.FindElement(By.XPath("//*[@id='ctl00_PageContentBody_tabControl_Propertys_T1T']")); IJavaScriptExecutor TV = driver as IJavaScriptExecutor; TV.ExecuteScript("arguments[0].click();", Tax_Value); Thread.Sleep(2000); List <string> List1 = new List <string>(); List <string> List2 = new List <string>(); List <string> List3 = new List <string>(); List <string> List4 = new List <string>(); int K = 0; IWebElement valuetableElement = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/div[2]/div/div[2]/div/div/table/tbody/tr/td/div[1]/table/tbody")); IList <IWebElement> valuetableRow = valuetableElement.FindElements(By.TagName("tr")); IList <IWebElement> valuerowTD; gc.CreatePdf(orderNumber, outparcelnowoh, "Current_Value.pdf", driver, "CA", "Santa Barbara"); foreach (IWebElement row in valuetableRow) { valuerowTD = row.FindElements(By.TagName("td")); if (valuerowTD.Count != 0 && valuerowTD.Count != 1 && Ok == "OK") { if (valuerowTD.Count == 2) { if (valuerowTD[0].Text.Trim() != "") { string Taxnumber = valuerowTD[0].Text; List4.Add(Taxnumber); } } else { if (valuerowTD[1].Text.Trim() != "" && valuerowTD[2].Text.Trim() != "" && valuerowTD[3].Text.Trim() != "") { string Value1 = valuerowTD[1].Text; List1.Add(Value1); string Value2 = valuerowTD[2].Text; List2.Add(Value2); string Value3 = valuerowTD[3].Text; List3.Add(Value3); } } } if (valuerowTD.Count != 0 && valuerowTD.Count != 1) { if (valuerowTD[0].Text.Contains("Tax Bills")) { if (K == 1) { Ok = "OK"; } K++; } } } Tax_Bills = List4[0] + "~" + List4[1] + "~" + List4[2]; Frow1 = List4[0] + "~" + List1[0] + "~" + List2[0] + "~" + List3[0]; Row1 = ""; for (int X = List1.Count - 1; X >= 0; X--) { Row1 = List1[X] + "~" + Row1; } Row1 = List4[0] + "~" + Row1 + "Wer"; Row1 = Row1.Replace("~Wer", ""); gc.insert_date(orderNumber, outparcelno, 259, Row1, 1, DateTime.Now); Frow2 = List4[0] + "~" + List1[0] + "~" + List2[0] + "~" + List3[0]; Row2 = ""; for (int X = List2.Count - 1; X >= 0; X--) { Row2 = List2[X] + "~" + Row2; } Row2 = List4[1] + "~" + Row2 + "Wer"; Row2 = Row2.Replace("~Wer", ""); gc.insert_date(orderNumber, outparcelno, 259, Row2, 1, DateTime.Now); Frow3 = List4[0] + "~" + List1[0] + "~" + List2[0] + "~" + List3[0]; Row3 = ""; for (int X = List3.Count - 1; X >= 0; X--) { Row3 = List3[X] + "~" + Row3; } Row3 = List4[2] + "~" + Row3 + "Wer"; Row3 = Row3.Replace("~Wer", ""); gc.insert_date(orderNumber, outparcelno, 259, Row3, 1, DateTime.Now); } catch { } //Tax Payment Receipts try { try { Tax_Receipt = driver.FindElement(By.XPath("//*[@id='ctl00_PageContentBody_tabControl_Propertys_T2T']")); } catch { } gc.CreatePdf(orderNumber, outparcelnowoh, "Current_Payment.pdf", driver, "CA", "Santa Barbara"); IJavaScriptExecutor TR = driver as IJavaScriptExecutor; TR.ExecuteScript("arguments[0].click();", Tax_Receipt); Thread.Sleep(2000); int i = 0; IWebElement TBTaxReceipts = driver.FindElement(By.XPath("/html/body/form/div[3]/div[2]/div[2]/div/div[2]/div/div[3]/div/table/tbody/tr/td/table[2]/tbody")); IList <IWebElement> TRTaxReceipts = TBTaxReceipts.FindElements(By.TagName("tr")); IList <IWebElement> TDTaxReceipts; gc.CreatePdf(orderNumber, outparcelno, "Current_Payment.pdf", driver, "CA", "Santa Barbara"); foreach (IWebElement TaxReceipt in TRTaxReceipts) { TDTaxReceipts = TaxReceipt.FindElements(By.TagName("td")); if (TDTaxReceipts.Count == 9) { Payment_Date = TDTaxReceipts[0].Text; Effective_PaymentDate = TDTaxReceipts[1].Text; BillNumber = TDTaxReceipts[2].Text; Year = TDTaxReceipts[3].Text; TaxBill_Type = TDTaxReceipts[4].Text; Installment = TDTaxReceipts[5].Text; Payment_Batch = TDTaxReceipts[6].Text; Payment_Type = TDTaxReceipts[7].Text; Payment_Amount = TDTaxReceipts[8].Text; Tax_Receipts = Payment_Date + "~" + Effective_PaymentDate + "~" + BillNumber + "~" + Year + "~" + TaxBill_Type + "~" + Installment + "~" + Payment_Batch + "~" + Payment_Type + "~" + Payment_Amount; gc.insert_date(orderNumber, outparcelno, 244, Tax_Receipts, 1, DateTime.Now); i++; } } } catch { } TaxTime = DateTime.Now.ToString("HH:mm:ss"); LastEndTime = DateTime.Now.ToString("HH:mm:ss"); gc.insert_TakenTime(orderNumber, "CA", "Santa Barbara", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime); driver.Quit(); //megrge pdf files gc.mergpdf(orderNumber, "CA", "Santa Barbara"); return("Data Inserted Successfully"); } catch (Exception ex) { driver.Quit(); throw ex; } } }
/// <summary> /// Gets a web element's CSS value by property name. /// </summary> /// <param name="actor">The actor.</param> /// <param name="driver">The WebDriver.</param> /// <returns></returns> public override string RequestAs(IActor actor, IWebDriver driver) { actor.WaitsUntil(Existence.Of(Locator), IsEqualTo.True()); return driver.FindElement(Locator.Query).GetCssValue(PropertyName); }
public void Close_Sendpulse() { wait.Until(ExpectedConditions.ElementToBeClickable(By.ClassName("sendpulse-disallow-btn"))); driver.FindElement(By.ClassName("sendpulse-disallow-btn")).Click(); }
public void GetURl(string Name, string Pass) { string Url = "http://m.ximalaya.com/login?fromUri=http%3A%2F%2Fpages.ximalaya.com%2Fcarnival123%2Fpromotion%3FpromotionId%3D932"; driver.Navigate().GoToUrl(Url); // //a[@class = 'fl j-tab '] Thread.Sleep(cint); driver.FindElement(By.XPath("//a[@class = 'fl j-tab ']")).Click(); driver.FindElement(By.XPath("//input[@class = 'input-num pdlBig pwl-number']")).SendKeys(Name); driver.FindElement(By.XPath("//input[@class = 'input-text pd-reset pwl-pass']")).SendKeys(Pass); Thread.Sleep(cint); driver.FindElement(By.XPath("//a[@class = 'btn login-register j-login on']")).Click(); Thread.Sleep(cint); driver.FindElement(By.XPath("//div[@class = 'bottom']")).Click(); //ęÆå¦å¼¹ę” try { Thread.Sleep(cint); // driver.Navigate().GoToUrl(Url); driver.FindElement(By.XPath("//img[@class = 'close']")).Click(); Thread.Sleep(cint); driver.FindElement(By.XPath("//div[@class = 'bottom']")).Click(); } catch (Exception) { } //if ( != null) //{ // //} Thread.Sleep(cint); driver.FindElement(By.XPath("//div[@class = 'btn buy logined _oX']")).Click(); Thread.Sleep(cint); string Uname = driver.FindElement(By.XPath("//p[@class = 'name elli']")).Text; Thread.Sleep(cint); driver.FindElement(By.XPath("//a[@class = 'btn-purchase j-submit']")).Click(); Thread.Sleep(cint); driver.FindElement(By.XPath("//i[@class = 'ic ic-wxpay']")).Click(); Thread.Sleep(cint); driver.FindElement(By.XPath("//a[@class = 'btn btn-primary j-pay']")).Click(); string UNumber = driver.FindElement(By.XPath("//span[@class = 'order-number']")).Text; string Piw = Name + "-" + Pass + "-" + Uname + "-" + UNumber; ShowInfo(Piw); File.AppendAllText(textBox5.Text + ".txt", "\r\n" + Piw); }
//Find and Click on Save Button public void ClickOnSave(IWebDriver driver) { IWebElement save = driver.FindElement(By.XPath("//*[@id='SaveButton']")); save.Click(); }
/// <summary> /// Fills the ActorScraper object with info by using a dict of actorName, actorImbdNumber strings. /// </summary> /// <param name="actorDict"></param> public void ScrapeActors(Dictionary <string, string> actorDict) { //Console.WriteLine("\r\nStarting IMDB scraping...", ProfileManager.InfoColor); foreach (var actor in actorDict) { var actorFullname = actor.Key; var actorName = actorFullname.Split(' ')[0]; var actorSurname = string.Join(" ", actorFullname.Split(' ').Skip(1)); var actorNumber = actor.Value; _driver.Navigate().GoToUrl(_baseUrl + "/name/" + actorNumber); var actorBirthday = string.Empty; try { actorBirthday = _driver.FindElement(By.XPath(".//*[@id=\'name-born-info\']/time")).GetAttribute("datetime"); } catch (NoSuchElementException) { } _driver.Navigate().GoToUrl(string.Format(_imdbActorFilmsTemplate, actorNumber)); var currentActor = new Actor(actorName, actorSurname, actorBirthday); // Scrape films from page while (true) { foreach (var filmElem in _driver.FindElements(By.XPath("//*[contains(@class,\'lister-item-content\')]"))) { var filmName = filmElem.FindElement(By.ClassName("lister-item-header")).FindElement(By.TagName("a")).Text; decimal filmRating = 0; try { var filmRatingStr = filmElem.FindElement(By.ClassName("ratings-imdb-rating")).FindElement(By.TagName("strong")).Text.Replace(',', '.'); filmRating = decimal.Parse(filmRatingStr, _decimalFormat); } catch (NoSuchElementException) { } var filmYear = string.Empty; try { var text = filmElem.FindElement( By.XPath(".//*[contains(@class, \'lister-item-year text-muted unbold\')]")).Text; filmYear = Regex.Match(text, @"\((\d{4})\)").Groups[1].Value; } catch (NoSuchElementException) { } var filmGenre = string.Empty; try { filmGenre = filmElem.FindElement(By.XPath(".//*[contains(@class, \'genre\')]")).Text.Trim(); } catch (NoSuchElementException) { } var currentFilm = new Film(filmName, filmRating, filmYear, filmGenre); currentActor.Films.Add(currentFilm); UniqueFilms.Add(currentFilm); } try { var nextBtn = _driver.FindElement(By.ClassName("next-page")); nextBtn.Click(); _wait.Until(ExpectedConditions.StalenessOf(nextBtn)); } catch (NoSuchElementException) { break; } } UniqueActors.Add(currentActor); } _driver.Quit(); //Console.WriteLine("Scraping complete.", ProfileManager.SuccessColor); }
public string VerifyPageTitle() { return(driver.FindElement(By.Id("page-title")).Text); }
public void TheCT02ReportandoProblemaTest() { driver.Navigate().GoToUrl(baseURL + "/login_page.php"); driver.FindElement(By.Name("username")).Clear(); driver.FindElement(By.Name("username")).SendKeys("leandro.matias"); driver.FindElement(By.Name("password")).Clear(); driver.FindElement(By.Name("password")).SendKeys("9087"); driver.FindElement(By.CssSelector("input.button")).Click(); // Seelcionando projeto new SelectElement(driver.FindElement(By.Name("project_id"))).SelectByText("Leandro MatiasĀ“s Project"); // Reportando problema driver.FindElement(By.LinkText("Report Issue")).Click(); // Reportanto detalhes new SelectElement(driver.FindElement(By.Name("category_id"))).SelectByText("[All Projects] Teste"); new SelectElement(driver.FindElement(By.Name("reproducibility"))).SelectByText("always"); new SelectElement(driver.FindElement(By.Name("severity"))).SelectByText("major"); new SelectElement(driver.FindElement(By.Name("priority"))).SelectByText("urgent"); new SelectElement(driver.FindElement(By.Name("profile_id"))).SelectByText("Desktop Windows 10"); driver.FindElement(By.Name("summary")).Clear(); driver.FindElement(By.Name("summary")).SendKeys("teste"); driver.FindElement(By.Name("description")).Clear(); driver.FindElement(By.Name("description")).SendKeys("teste teste"); driver.FindElement(By.Name("steps_to_reproduce")).Clear(); driver.FindElement(By.Name("steps_to_reproduce")).SendKeys("teste > teste"); driver.FindElement(By.Name("additional_info")).Clear(); driver.FindElement(By.Name("additional_info")).SendKeys("nenhuma"); driver.FindElement(By.CssSelector("input.button")).Click(); }
public void TheUntitledTestCaseTest() { driver.Navigate().GoToUrl("https://elp.duetbd.org/"); driver.FindElement(By.LinkText("Log in")).Click(); driver.FindElement(By.Id("username")).Click(); driver.FindElement(By.Id("username")).Clear(); driver.FindElement(By.Id("username")).SendKeys("170042042"); driver.FindElement(By.Id("password")).Click(); driver.FindElement(By.Id("password")).Clear(); driver.FindElement(By.Id("password")).SendKeys("Rifah.42"); driver.FindElement(By.Id("loginbtn")).Click(); driver.FindElement(By.XPath("//nav[@id='header']/div")).Click(); driver.FindElement(By.Id("action-menu-toggle-1")).Click(); driver.FindElement(By.Id("actionmenuaction-6")).Click(); }
public void clicarMenuSimulacao() { driver.Navigate().GoToUrl("localhost:3000"); IWebElement menu_simulacao = driver.FindElement(By.Id("id_simula_index")); menu_simulacao.Click(); }
public void CreateUser(User user) { String Fname = "FirstName"; IWebElement FirstName = driver.FindElement(By.Name(Fname)); FirstName.SendKeys(user.FirstName); String Lname = "LastName"; IWebElement LastName = driver.FindElement(By.Name(Lname)); LastName.SendKeys(user.LastName); String Uname = "UserName"; IWebElement UserName = driver.FindElement(By.Name(Uname)); UserName.SendKeys(user.Username); String Pword = "Password"; IWebElement Password = driver.FindElement(By.Name(Pword)); Password.SendKeys(user.Username); string optionsRadios = "optionsRadios"; IWebElement optionsRadiosCntl = driver.FindElement(By.Name(optionsRadios)); if (user.Customer.Equals("ABSA")) { driver.FindElement(By.XPath("/html/body/div[3]/div[2]/form/table/tbody/tr[5]/td[2]/label[1]/input")).Click(); } else { driver.FindElement(By.XPath("/html/body/div[3]/div[2]/form/table/tbody/tr[5]/td[2]/label[2]/input")).Click(); } String role = "RoleId"; IWebElement roles = driver.FindElement(By.Name(role)); roles.SendKeys(user.Role); roles.SendKeys(Keys.Enter); driver.FindElement(By.Name("Email")).SendKeys(user.Email); driver.FindElement(By.Name("Mobilephone")).SendKeys(user.Cell); driver.FindElement(By.XPath("/html/body/div[3]/div[3]/button[2]")).Click(); }
public void EfetuaCadastro() { driver.FindElement(byBotaoSolicitaCadastro).Click(); }
public static string GetText(this IWebDriver webDriver, By by) { IWebElement webElement = webDriver.FindElement(by); return(webElement.Text); }
public void WhenIEnterUsernameAndPasswordOfUser(Table table) { driver.FindElement(By.Id("user_login")).SendKeys("*****@*****.**"); driver.FindElement(By.Id("user_pass")).SendKeys("user123"); }
public void WhenIPressTheLoginLink() { driver.FindElement(By.Id("lst-ib")).SendKeys("Unicorns"); }
public void AdminLogin() { //*********Author Atif Nawaz********* try { // insert url IEdriver.Manage().Window.Maximize(); var URL = "https://admin.qadesktopus.local"; IEdriver.Navigate().GoToUrl(URL); System.Threading.Thread.Sleep(1000); //Username var U_name = "admin"; var User_Name = IEdriver.FindElement(admObject.Admin_username); User_Name.Clear(); System.Threading.Thread.Sleep(1000); CommonFunction.SetText(User_Name, U_name); System.Threading.Thread.Sleep(1000); //Password var PW = "Admin@1234"; System.Threading.Thread.Sleep(1000); IWebElement admPass = IEdriver.FindElement(admObject.Admin_Password); // System.Threading.Thread.Sleep(2000); admPass.Clear(); System.Threading.Thread.Sleep(2000); admPass.Clear(); CommonFunction.SetText(admPass, PW); System.Threading.Thread.Sleep(1000); //Add Pin Code var lab_pin = IEdriver.FindElement(admObject.Admin_LabelCode); string strPin = lab_pin.Text.ToString(); // Adding the pin code string values var Substring0 = strPin.Substring(0, 1); var Substring1 = strPin.Substring(1, 1); var Substring2 = strPin.Substring(2, 1); var Substring3 = strPin.Substring(3, 1); int result = int.Parse(Substring0) + int.Parse(Substring1) + int.Parse(Substring2) + int.Parse(Substring3); var str_result = result.ToString(); var str_result_length = str_result.Length; //Condition on if string is above 10 and below 10 if (str_result_length == 2) { var resultsubstring1 = str_result.Substring(0, 1); var resultsubstring2 = str_result.Substring(1, 1); int resultTotal = int.Parse(resultsubstring1) + int.Parse(resultsubstring2); var stringdoublevalue = resultTotal.ToString() + resultTotal.ToString(); var pincodefield = IEdriver.FindElement(admObject.Admin_PinCode); pincodefield.Clear(); System.Threading.Thread.Sleep(1000); CommonFunction.SetText(pincodefield, stringdoublevalue); System.Threading.Thread.Sleep(1000); } else { var Singledigit = str_result + str_result; var pincodefield = IEdriver.FindElement(admObject.Admin_PinCode); pincodefield.Clear(); System.Threading.Thread.Sleep(1000); pincodefield.SendKeys(Singledigit); System.Threading.Thread.Sleep(1000); } //login button of admin page var Login_Button = IEdriver.FindElement(admObject.Admin_LoginButton); Login_Button.Click(); System.Threading.Thread.Sleep(2000); } catch (Exception e) { Console.WriteLine("Admin login function exception: " + e); } }
public void WhenIEnterPostcode() { postcodeField = driver.FindElement(By.Name("PostCode")); postcodeField.SendKeys("M8 8YG"); }
/// <summary> /// Open the Form and fill it with the information. /// </summary> /// <param name="number"></param> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="address"></param> /// <param name="country"></param> /// <param name="state"></param> /// <param name="zip"></param> /// <param name="nameOnCard"></param> /// <param name="creditCardNumber"></param> /// <param name="expirationDate"></param> /// <param name="cvv"></param> /// <returns>true if the form is submitted</returns> internal bool FillForm( string firstName, string lastName, string userName, string address, string country, string state, string zip, string nameOnCard, string creditCardNumber, string expirationDate, string cvv) { driver.Navigate().GoToUrl(@"https://getbootstrap.com/docs/4.1/examples/checkout/"); // User info driver.FindElement(By.Id("firstName")).SendKeys(firstName); driver.FindElement(By.Id("lastName")).SendKeys(lastName); driver.FindElement(By.Id("username")).SendKeys(userName); driver.FindElement(By.Id("address")).SendKeys(address); new SelectElement(driver.FindElement(By.Id("country"))).SelectByText(country); new SelectElement(driver.FindElement(By.Id("state"))).SelectByText(state); driver.FindElement(By.Id("zip")).SendKeys(zip); // Credit card info driver.FindElement(By.Id("cc-name")).SendKeys(nameOnCard); driver.FindElement(By.Id("cc-number")).SendKeys(creditCardNumber); driver.FindElement(By.Id("cc-expiration")).SendKeys(expirationDate); driver.FindElement(By.Id("cc-cvv")).SendKeys(cvv); // Submit the form driver.FindElement(By.CssSelector("button.btn.btn-primary.btn-lg.btn-block")).Click(); // When the form is submitted, all the fields are emptied. // So if firstName is empty, it was a success. return(driver.FindElement(By.Id("firstName")).GetAttribute("value").Length == 0); }
public void Test1() { IWebElement newsButton = driver.FindElement(By.XPath("//div[@id='orb-nav-links']//a[contains(text(), 'News')]")); newsButton.Click(); IWebElement topNews = driver.FindElement(By.XPath("//div[@data-entityid='container-top-stories#1']/div[1]//h3")); string actualTopNews = topNews.Text; string expectedTopNews = "China coronavirus deaths and cases spike"; Assert.AreEqual(actualTopNews, expectedTopNews); driver.Quit(); }
public void GivenRequisitionIDJobCodeAndAccordingToJobCodeSelectRequisitionID() { driver.Navigate().GoToUrl("http://172.16.1.63/gmtproduction"); driver.Manage().Window.Maximize(); Thread.Sleep(2000); driver.FindElement(By.Id("UserName")).SendKeys("nigar"); //Enter Password Thread.Sleep(2000); driver.FindElement(By.Id("Password")).SendKeys("d123"); //Click Login Button driver.FindElement(By.Id("loginBtn")).Click(); //Click Fabric Menu //driver.FindElement(By.XPath("//*[@id='MenuListLoad']/ul/li[3]/a/text()")).Click(); Thread.Sleep(2000); //Click Fabric Menu driver.FindElement(By.XPath("//*[@id='MenuListLoad']/ul/li[3]/a")).Click(); Thread.Sleep(2000); // Click Sub Menu Issue driver.FindElement(By.XPath("//*[@id='MenuListLoad']/ul/li[3]/ul[2]/li/a")).Click(); }
//Find and Click on create button public void ClickOnCreate(IWebDriver driver) { IWebElement createbtn = driver.FindElement(By.XPath("//*[@id='container']/p/a")); createbtn.Click(); }
public void LogOut() { // Log out _driver.FindElement(By.XPath("//*[@id='header']/div[2]/div/div/nav/div[2]/a")).Click(); }
public void InputUserName(String userName) { new WebDriverWait(webdriver, TimeSpan.FromSeconds(Constants.WAIT_TIME_DEFAULT)).Until(ExpectedConditions.ElementToBeClickable(userNameInput)); webdriver.FindElement(userNameInput).SendKeys(userName); }