public void Finally(IWebDriver driver, string url, Datarow datarow, string emails) { new GeneralLibrary(); try { //Footer_TPS footer = new Footer_TPS(); //footer.Footer(driver, , url, datarow); //Baskets_TPS basket = new Baskets_TPS(); //basket.Basket(driver, datarow); //links_TPS hom = new links_TPS(); //hom.Links(datarow,driver, url); //UserJourney_TPS userjour = new UserJourney_TPS(); //userjour.UserJourn(datarow,driver, url); //Mopay_TPS Mopay = new Mopay_TPS(); //Mopay.Mopay(driver, datarow); } catch (Exception e) { Console.Write(e); var ex = e.ToString(); var scree = new Screenshot(); datarow.Newrow("Exception", "Not Expected", ex, "FAIL", driver); scree.Screenshotfailed(driver); } finally { var split = url.Split(new[] {' ', ',', '.', '/', '\t'}); foreach (var sr in split) { if (split[2] == "m" || split[2] == "www") { if (sr != split[3]) continue; datarow.consolidatedreport(emails); datarow.Excelsave("Mosite-" + sr + "", driver, emails); driver.Quit(); break; } if (sr != split[2]) continue; datarow.consolidatedreport(emails); datarow.Excelsave("Mosite-" + sr + "", driver, emails); driver.Quit(); break; } } }
public void OpenGooglePage() { driver = getDriver(browser); Console.WriteLine("testing"); driver.Navigate().GoToUrl(pageUrl); driver.Quit(); }
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"); }
public void ChromeStartup() { dr = new ChromeDriver(); dr.Manage().Window.Maximize(); dr.Navigate().GoToUrl(url); dr.Quit(); }
public void AfterScenario(ScenarioContext scenarioContext) { extent.Flush(); driver?.Quit(); driver?.Dispose(); GC.SuppressFinalize(this); }
public void TearDown() { _driver?.Quit(); _driver?.Dispose(); _edgeService?.Dispose(); _firefoxService?.Dispose(); }
public override void Dispose() { if (!_disposed) { Current = null; _disposed = true; IWebElement JSErrors = null; try { JSErrors = driver.FindElement(By.Id("JSErrors")); } catch { } if (JSErrors != null) { verificationErrors.Append(JSErrors.Text); } try { driver?.Quit(); driver = null; } catch (Exception) { // Ignore errors if unable to close the browser } base.Dispose(); Assert.Equal("", verificationErrors.ToString()); } }
protected virtual void Dispose(bool disposing) { if (_status == ContextStatus.Disposed) { return; } if (disposing) { if (_driverName != null) { if (_useDriverBarrier) { WebDriverManager.Instance.ReleaseBarrier(_driverName); } WebDriverManager.Instance.ReleaseReference(_driverName); } else { _webDriver?.Quit(); } _barrier?.Set(); } _status = ContextStatus.Disposed; }
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(); } }
public void CleanUpAfterEveryTestMethod() { var passed = TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed; ((IJavaScriptExecutor)_driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed")); _driver?.Quit(); }
public void selects_moved_to_single_method() { var profile = new FirefoxProfile(); var exe = new FirefoxBinary(@"D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); browser = new FirefoxDriver(exe, profile); wait = new WebDriverWait(browser,TimeSpan.FromSeconds(10)); //browser.Navigate().GoToUrl("http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/CascadingDropDown/CascadingDropDown.aspx"); browser.Navigate().GoToUrl("http://localhost/AJAXDemos/CascadingDropDown/CascadingDropDown.aspx"); wait_on_menu_item(1, "Acura"); select_menu_item(1, "Acura"); wait_on_menu_item(2, "Integra"); select_menu_item(2, "Integra"); wait_on_menu_item(3, "Sea Green"); select_menu_item(3, "Sea Green"); wait.Until( ExpectedConditions.ElementExists( By.XPath("//span[@id='ctl00_SampleContent_Label1' and text()='You have chosen a Sea Green Acura Integra. Nice car!']"))); browser.Quit(); }
/// <summary> /// Close the browser /// </summary> public void Dispose() { Log.Info("Disposing Browser"); Thread.Sleep(1000); NgDriver?.Quit(); Driver?.Quit(); }
public void Mositestart(IWebDriver driver) { new GeneralLibrary(); try { _datarow.Col(); // new Modrophenialive().modrophenialiveproducts(, driver); new Modropheniaproducts().Product(_datarow, driver); // new UserJourney().UserJourn(this.datarow,driver); // new UserData().Userdata(this.datarow,driver); // new Mopaysite().MoPay(driver, , this.datarow); } catch (Exception exception) { Console.Write(exception); var actual = exception.ToString(); var screenshot = new Screenshot(); _datarow.Newrow("Exception", "Not Expected", actual, "FAIL", driver); screenshot.Screenshotfailed(driver); } finally { _datarow.Excelsave("MoSiteReport", driver, "*****@*****.**"); _datarow.Dataflush(); driver.Quit(); } }
private void SomeMethod() { //Selenium Integrations try { driver.Navigate().GoToUrl(@"https://www.google.com"); driver.FindElement(By.Name("q")).SendKeys("kenan"); var searchButton = driver.FindElement(By.Name("btnK")); searchButton.Click(); } catch (Exception ex) { Console.WriteLine("hata"); Console.WriteLine(ex.Message); } finally { System.Threading.Thread.Sleep(10000); driver?.Quit(); } var result = new SuccessResult <VisitResult>() { Data = new VisitResult { SomeData = "kenan" } }; callback.Invoke(result, driver); }
public void TearDown() { _driverChrome?.Quit(); _driverOpera?.Quit(); _driverFirefox?.Quit(); _driverExplorer?.Quit(); }
public virtual void ChromeTest() { if (!NareshScalerSettings.Default.ChromeEnabled) return; var driverDir = GetDriverDirectory(); try { driver = new ChromeDriver(driverDir); } catch (Exception) { // Only for master build var masterLibDir = LocateDir(Directory.GetCurrentDirectory(), "lib"); driver = new ChromeDriver(masterLibDir); } driver.Manage().Timeouts().ImplicitlyWait(DefaultTimeOutValue); try { RunSeleniumTests(); driver.Quit(); } catch (Exception e) { RecordError(e); } }
public void Teardown() { var isPassed = TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed; _sauceLogger.LogTestStatus(isPassed, "Test finished execution"); _driver?.Quit(); }
/// <summary> /// Basic way of selecting options of a select element. /// </summary> public void SelectCheese(string url) { try { _driver = Browser.GetFirefoxDriver(); _driver.Navigate().GoToUrl(url); IWebElement select = _driver.FindElement(By.TagName("select")); IList<IWebElement> allOptions = select.FindElements(By.TagName("option")); foreach (var option in allOptions) { System.Console.WriteLine("Value is:" + option.GetAttribute("value")); option.Click(); } } catch (System.InvalidOperationException ex) { Console.WriteLine("An Invalid operations exception occured: " + ex.Message); Debug.WriteLine("An Invalid operations exception occured: " + ex.Message); } catch (System.Exception ex) { Console.WriteLine("An exception occured: " + ex.Message); Debug.WriteLine("An exception occured: " + ex.Message); } finally { _driver.Quit(); } }
public void CleanUpAfterEveryTestMethod() { var passed = TestContext.CurrentTestOutcome == UnitTestOutcome.Passed; ((IJavaScriptExecutor)_driver).ExecuteScript("sauce:context=" + "Stop Test"); ((IJavaScriptExecutor)_driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed")); _driver?.Quit(); }
public void BrowserTearDown() { NonAngularWebDriver?.Quit(); NonAngularWebDriver?.Dispose(); Driver?.Quit(); Driver?.Dispose(); DriverSetup?.StopServices(); }
public void Teardown() { //Closing the driver. AdidasDriver?.Quit(); AdidasDriver.Quit(); AdidasDriver.Dispose(); AdidasDriver = null; }
public void AfterAll() { _driver?.Quit(); if (!Env.ServerIsRemote()) { AppiumServers.StopLocalService(); } }
public void OneTimeTearDown() { // Quits driver and closes every associated window _driver?.Quit(); // Disposes html report _htmlReport.Flush(); }
public void CloseWebDriver() { testOutputHelper.WriteLine($"Removing web driver"); webDriver?.Quit(); webDriver?.Dispose(); webDriver = null; }
public void Mosite(IWebDriver driver, Datarow datarow, string urls, string items) { var screenshot = new Screenshot(); var strArray = items.Split(new[] {','}); var urlarray = urls.Split(new[] {','}); try { foreach (var url in urlarray) { foreach (var str in strArray.Where(str => str != null)) { if (str == "Test All Links in Mosite") { datarow.Newrow("", "", "Test All Links in Mosite", "", driver); var tick = new Tickle(); tick.HomepageTabsTickle(datarow, driver, url); } if (str == "Test Footer Links") { datarow.Newrow("", "", "Test Footer Links", "", driver); } if (str == "Test Basket Functionality") { datarow.Newrow("", "", "Test Basket Functionality", "", driver); } if (str == "Test Produict Page - Test Add Product to Basket") { datarow.Newrow("", "", "Test Produict Page - Test Add Product to Basket", "", driver); } if (str == "Test Delete From Basket - Test Product Unavailable") { datarow.Newrow("", "", "Test Delete From Basket - Test Product Unavailable", "", driver); } if (str == "Test Registration/Login - CheckOut Pages") { datarow.Newrow("", "", "Test Registration/Login - CheckOut Pages", "", driver); } if (str == "Test Mopay") { datarow.Newrow("", "", "Test Mopay", "", driver); } } } } catch (Exception) { datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver); screenshot.Screenshotfailed(driver); } finally { datarow.Excelsave("MoshopConsole", driver, "*****@*****.**"); screenshot.Screenshotfailed(driver); driver.Quit(); } }
public void TearDown() { //Checks the status of the test and passes the result to the Sauce Labs job var passed = TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed; ((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed")); driver?.Quit(); }
public static void Shutdown() { Browser?.Quit(); Browser = null; CheckIfBrowserRunningTask?.Wait(); CheckIfBrowserRunningTask?.Dispose(); CheckIfBrowserRunningTask = null; }
public void AfterScenario() { if (ScenarioContext.Current.TestError != null) { _screenshotHelper.TakeScreenshot(_driver); } _driver?.Quit(); DriverHolder.Utilize(); }
public void Cleanup() { var passed = TestContext.CurrentTestOutcome == UnitTestOutcome.Passed; if (_driver != null) { ((IJavaScriptExecutor)_driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed")); } _driver?.Quit(); }
static void Main(string[] args) { errstring = ""; w("START"); w(" Initialize variables, set up outfiles"); apppath = curdir(); appname = curname(); xlname = appname + ".xls"; xlpath = apppath + "\\" + xlname; logname = appname + ".log"; mkdir("results"); curpath = "results\\" + dtstring() + "-" + appname; webfile = appname + ".html"; mkdir(curpath); webpath = curpath + "\\" + webfile; logpath = curpath + "\\" + logname; w(" Fetch variables from the Excel sheet"); openXL(xlpath); targetURL = getXLParm("targetURL"); uid = getXLParm("uid"); uname = getXLParm("uname"); pid = getXLParm("pid"); pw = getXLParm("pword"); submitid = getXLParm("submitID"); webfile = getXLParm("webfile"); test = getXLParm("test"); webfile = datestring + "-" + webfile; closeXL(); //w(" Open browser"); //d = new FirefoxDriver(); d = new ChromeDriver(); w(" Navigate to the login screen"); go (targetURL); w(" Login"); w(" Run the tests - as indicated in the Excel sheet"); exec(test); //Close and clean up browser stuff w("Clean up"); d.Close(); d.Quit(); w("END"); //Output results to web page and display it writeHTML(webpath); string webspec = apppath + "/" + webpath; startIE(webspec); }
public void CatalogTestExplorer() { Logger logger = new Logger("CatalogTestLoggerForExplorer.txt"); explorerDriver = new InternetExplorerDriver(AppDomain.CurrentDomain.BaseDirectory, new InternetExplorerOptions(), new TimeSpan(0, 10, 0)); logger.Log("Start Explorer testing"); CatalogTest(explorerDriver, logger); logger.Log("Close browser"); logger.Dispose(); if (explorerDriver != null) explorerDriver.Quit(); }
public void CatalogTestFirefox() { Logger logger = new Logger("CatalogTestLoggerForFirefox.txt"); firefoxDriver = new FirefoxDriver(); logger.Log("Start Firefox testing"); CatalogTest(firefoxDriver, logger); logger.Log("Close browser"); logger.Dispose(); if (firefoxDriver != null) firefoxDriver.Quit(); }
public void CatalogTestChrome() { Logger logger = new Logger("CatalogTestLoggerForChrome.txt"); chromeDriver = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory); logger.Log("Start Chrome testing"); CatalogTest(chromeDriver, logger); logger.Log("Close browser"); logger.Dispose(); if (chromeDriver != null) chromeDriver.Quit(); }
/// <summary> /// Make sure the web driver is shut down /// </summary> /// <param name="driver">The web driver</param> public static void KillDriver(this IWebDriver driver) { try { driver?.Close(); } finally { driver?.Quit(); } }
private void FormMain_FormClosing(object sender, FormClosingEventArgs e) { Hide(); ShowInTaskbar = false; _driver?.Quit(); foreach (var process in Process.GetProcessesByName("chromedriver")) { process.Kill(); } Application.Exit(); }
public static void AfterFeature() { _driver?.Quit(); //_driver?.Close(); //extent.Flush(); //extent.Close(); _extent.Flush(); // Sikuli Stop //launcher.Stop(); }
private void DisposeWebDriver(IWebDriver webDriver, string webDriverType) { try { webDriver?.Quit(); webDriver?.Dispose(); } catch (Exception ex) { Trace.WriteLine(ex, $"{webDriverType} stop error"); } }
public void TearDpwn() { var handles = _driver.WindowHandles; if (handles.Count == 2) { _driver.Close(); _driver.SwitchTo().Window(handles.First()); } _driver?.Close(); _driver?.Quit(); }
public void RefreshDriver() { Driver?.Quit(); var options = new FirefoxOptions(); if (RunHeadless) { options.AddArguments("-headless"); } Driver = new FirefoxDriver(options); }
public static void Quit() { _webDriver?.Close(); _webDriver?.Quit(); Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver"); foreach (var chromeDriverProcess in chromeDriverProcesses) { chromeDriverProcess.Kill(); } _webDriver = null; }
public void LogInToMailboxUsingFactory() { driver = new ChromeDriver(driverPath); driver.Manage().Window.Maximize(); IWebDriver decorDriver = new Decorator(driver); decorDriver.Navigate().GoToUrl("https://mail.ru/"); LoginPage lp = new LoginPage(decorDriver); lp.SetUserNamePassword(); MainPage mp = lp.ClickLoginButton(); Assert.IsTrue(mp.loginEmail.Text.ToLower().Equals(lp.Email)); mp.LogOut(); driver.Quit(); }
public void TestFailure() { VisualGridRunner visualGridRunner = new VisualGridRunner(10); visualGridRunner.SetLogHandler(TestUtils.InitLogHandler()); Size[] ViewportList = { new Size(800, 600), new Size(700, 500), new Size(1200, 800), new Size(1600, 1200) }; IWebDriver webDriver = SeleniumUtils.CreateChromeDriver(); webDriver.Url = "https://applitools.com/helloworld"; Eyes eyes = null; try { int resultsTotal = 0; foreach (Size viewport in ViewportList) { eyes = InitEyes_(null, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.Close(); eyes = InitEyes_(visualGridRunner, webDriver, viewport); eyes.Check(Target.Window().Fully()); eyes.Close(); TestResultsSummary results = visualGridRunner.GetAllTestResults(); resultsTotal += results.Count; } Assert.AreEqual(4, resultsTotal); } catch (InvalidOperationException e) { if (e.Message.Equals("Eyes not open")) { Assert.Pass(); } } finally { webDriver?.Quit(); eyes?.Abort(); } }
/// <summary>called at the end of each test to tear it down</summary> public void CleanUp(IWebDriver _Driver) { // get the status of the current test bool passed = TestContext.CurrentContext.Outcome.Status == TestStatus.Passed; try { // log the result to sauce labs ((IJavaScriptExecutor)_Driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed")); } finally { // terminate the remote webdriver session _Driver.Quit(); } }
public void Close(IWebDriver webDriver) { try { if (_webDriverList.Contains(webDriver)) { _webDriverList.TryTake(out webDriver); webDriver.Quit(); } } catch (Exception) { // ignored } }
public static void Dispose(IWebDriver webDriver, ServicesCollection container) { try { webDriver?.Quit(); webDriver?.Dispose(); container?.UnregisterSingleInstance <IWebDriver>(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } ProcessCleanupService.KillPreviousDriversAndBrowsersOsAgnostic(TestRunStartTime); }
public static void Dispose(IWebDriver webDriver, ServicesCollection container) { try { webDriver?.Close(); webDriver?.Quit(); webDriver?.Dispose(); container?.UnregisterSingleInstance <IWebDriver>(); } catch (Exception ex) { DebugInformation.PrintStackTrace(ex); } ProcessCleanupService.KillPreviousDriversAndBrowsersOsAgnostic(TestRunStartTime); }
public void Execute() { driver = new FirefoxDriver(); baseURL = "http://only-testing-blog.blogspot.in/"; verificationErrors = new StringBuilder(); driver.Navigate().GoToUrl(baseURL + "/2014/01/textbox.html"); Thread.Sleep(3000); driver.FindElement(By.Name("img")).Clear(); driver.FindElement(By.Name("img")).SendKeys("ribbon-black_68.png"); Console.WriteLine("Wait 14 sec before clicking submit"); Thread.Sleep(15000); driver.FindElement(By.Id("submitButton")).Click(); Console.WriteLine("Submitted file Will wait for 20 more sec"); Thread.Sleep(20000); driver.Quit(); }
public void TestFixtureTearDown() { if (TestContext.CurrentContext.Result.Outcome != ResultState.Success && Driver != null) { var screenshot = ((ITakesScreenshot)Driver).GetScreenshot(); var dirPath = "C:\\selenium"; if (!Directory.Exists(dirPath)) { throw new Exception($"I cannot make a screenshot of the failed test because the directory {dirPath} does not exist"); } string filePath = $"{dirPath}\\Test fail {GetSafeFilename(TestContext.CurrentContext.Test.FullName)}.png"; screenshot.SaveAsFile(filePath, ScreenshotImageFormat.Png); } Driver?.Quit(); }
public static void SearchTheWeb(IWebDriver driver,string Url) { // And now use this to visit Google //driver.get("http://www.google.com"); driver.Navigate().GoToUrl(Url); // Find the text input element by its name IWebElement element = driver.FindElement(By.Name("q")); // Enter something to search for element.SendKeys("Cheese!"); // Now submit the form. WebDriver will find // the form for us from the element element.Submit(); // Check the title of the page System.Console.Out.WriteLine( "Page title is: " + driver.Title); driver.Quit(); }
public void Execute() { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("browser.helperApps.alwaysAsk.force", false); profile.SetPreference("browser.download.folderList", 2); profile.SetPreference("browser.download.dir", Directory.GetCurrentDirectory()); profile.SetPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false); profile.SetPreference("browser.download.useDownloadDir", true); profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/csv"); driver = new FirefoxDriver(profile); baseURL = ""; verificationErrors = new StringBuilder(); driver.Navigate().GoToUrl(baseURL + "/"); driver.FindElement(By.LinkText("Classic Login")).Click(); driver.FindElement(By.Name("uname")).Clear(); driver.FindElement(By.Name("uname")).SendKeys(""); driver.FindElement(By.Name("pword")).Clear(); driver.FindElement(By.Name("pword")).SendKeys(""); driver.FindElement(By.CssSelector("input[type=\"submit\"]")).Click(); driver.FindElement(By.LinkText("Submit File for Analysis")).Click(); driver.FindElement(By.LinkText("History of Submissions")).Click(); driver.FindElement(By.LinkText("X12out_final.txt")).Click(); driver.FindElement(By.XPath("//input[@value='csv']")).Click(); driver.FindElement(By.Name("report")).Click(); Console.WriteLine("Run autoit"); RunSaveProc(); Console.WriteLine("Will wait for 15 sec"); Thread.Sleep(12000); Console.WriteLine("Logging out"); driver.FindElement(By.LinkText("Logout")).Click(); driver.Quit(); }
//Clean and Destroy drivers and processes public static void Destroy(IWebDriver driver) { try { driver.Close(); driver.Quit(); Process[] processes = Process.GetProcessesByName("IEDriverServer"); if (processes.Length > 0) { KillProcessByName("iexplore"); KillProcessByName("IEDriverServer"); } processes = Process.GetProcessesByName("chromedriver"); if (processes.Length > 0) { KillProcessByName("chrome"); KillProcessByName("chromedriver"); } } catch (Exception) { } }
public void MoPay(IWebDriver driver) { _generalLibrary = new GeneralLibrary(); var excelData = _generalLibrary.GetExcelData(@"C:\\Input Data\CardDetails.xls", "CardDetails"); var set2 = _generalLibrary.GetExcelData(@"C:\\Input Data\CardDetails.xls", "Account"); _datarow.Col(); var table = excelData.Tables[0]; var table2 = set2.Tables[0]; var count = table2.Rows.Count; try { for (var i = 0; i < count; i++) { var locator = table2.Rows[i]["Account"].ToString(); var str2 = table2.Rows[i]["Type"].ToString(); var str3 = table2.Rows[i]["E-mail"].ToString(); var str4 = table2.Rows[i]["FormData"].ToString(); var str5 = table2.Rows[i]["FormValue"].ToString(); var str6 = table2.Rows[i]["CookieData"].ToString(); var str7 = table2.Rows[i]["CookieValue"].ToString(); driver.Navigate().GoToUrl("http://devpaytest.mobankdev.com/"); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(15.0)); driver.FindElement(By.XPath("//div[@id='ReferenceControl']/div/input")); driver.FindElement(By.XPath(locator)).Click(); driver.FindElement(By.Id(locator)).Click(); driver.FindElement(By.Id(str2)).Click(); driver.FindElement(By.XPath("//div[@id='ReferenceControl']/div/input")) .GetAttribute("Reference"); driver.FindElement(By.XPath("//div[@id='TotalAmountControl']/div/input")).GetAttribute("Amt"); driver.FindElement(By.XPath("//div[@id='CurrencyCodeControl']/div/select")).GetAttribute("Cur"); var input = table.Rows[0]["FirstName"].ToString(); var str12 = table.Rows[0]["LastName"].ToString(); Assert.AreEqual("The MoShop Sale", driver.FindElement(By.XPath("//div[@id='DescriptionControl']/div/textarea")).Text); var screenshot = new Screenshot(); driver.FindElement(By.XPath("//div[@id='FirstNameControl']/div/input")).Clear(); driver.FindElement(By.XPath("//div[@id='FirstNameControl']/div/input")).SendKeys(input); driver.FindElement(By.XPath("//div[@id='LastNameControl']/div/input")).Clear(); driver.FindElement(By.XPath("//div[@id='LastNameControl']/div/input")).SendKeys(str12); driver.FindElement(By.XPath("//div[@id='EmailControl']/div/input")).Clear(); driver.FindElement(By.XPath("//div[@id='EmailControl']/div/input")).SendKeys(str3); driver.FindElement(By.CssSelector("button")).Click(); driver.FindElement(By.Name("FormData[1].Key")).SendKeys(str4); driver.FindElement(By.Name("FormData[1].Value")).SendKeys(str5); driver.FindElement(By.CssSelector("#CookieData > button")).Click(); driver.FindElement(By.Name("CookieData[1].Key")).SendKeys(str6); driver.FindElement(By.Name("CookieData[1].Value")).SendKeys(str7); driver.FindElement(By.CssSelector("input[type=\"submit\"]")).Click(); try { } catch (Exception exception) { Console.Write(exception); } var num3 = table.Rows.Count; for (var j = 0; j < num3; j++) { var str13 = table.Rows[j]["Card Number"].ToString(); var str14 = table.Rows[j]["Security Code"].ToString(); var expected = table.Rows[j]["CardType"].ToString(); var str16 = table.Rows[j]["Name on Card"].ToString(); var optionLocator = table.Rows[j]["ExpiryMonth"].ToString(); var str18 = table.Rows[j]["Expiry Year"].ToString(); var str19 = table.Rows[j]["Phone Number"].ToString(); var str20 = table.Rows[j]["Address"].ToString(); var str21 = table.Rows[j]["City"].ToString(); var str22 = table.Rows[j]["Post Code"].ToString(); var str23 = table.Rows[j]["County"].ToString(); var str24 = table.Rows[j]["Country"].ToString(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60.0)); driver.FindElement(By.XPath("//div[@id='Card.NameControl']/input")); Assert.AreEqual("Secure Payment Page", driver.Title); driver.FindElement(By.XPath("//*[@id='Card_Number']")).SendKeys(str13); driver.FindElement(By.Id("//*[@id='Card_SecurityCode']")).SendKeys(str14); new SelectElement(driver.FindElement(By.Id("Card_Type"))).SelectByText("Visa Debit"); new SelectElement(driver.FindElement(By.Id("Card_ExpiryDate_Month"))).SelectByText(optionLocator); new SelectElement(driver.FindElement(By.Id("Card_ExpiryDate_Year"))).SelectByText(str18); driver.FindElement(By.XPath("//div[@id='Card.NameControl']/input")).SendKeys(str16); switch (str2) { case "id=actionPay": driver.FindElement(By.Id("BillingContact_Phone_Number")).SendKeys(str19); driver.FindElement(By.Id("BillingContact_Address_Line1")).SendKeys(str20); driver.FindElement(By.XPath("//div[@id='BillingContact.Address.Line2Control']/input")) .SendKeys("s"); driver.FindElement(By.Id("BillingContact_Address_Postcode")).SendKeys(str22); driver.FindElement(By.XPath("//div[@id='BillingContact.Address.TownControl']/input")) .SendKeys(str21); driver.FindElement(By.Id("BillingContact_Address_County")).SendKeys(str23); new SelectElement( driver.FindElement( By.XPath("//div[@id='BillingContact.Address.CountryControl']/div/div/select"))) .SelectByText(str24); break; case "id=actionToken": driver.FindElement(By.Id("Contact_Phone_Number")).SendKeys(str19); driver.FindElement(By.Id("Contact_Address_Line1")).SendKeys(str20); driver.FindElement(By.XPath("//div[@id='Contact.Address.Line2Control']/input")) .SendKeys("s"); driver.FindElement(By.Id("Contact_Address_Postcode")).SendKeys(str22); driver.FindElement(By.XPath("//div[@id='Contact.Address.TownControl']/input")) .SendKeys(str21); driver.FindElement(By.Id("Contact_Address_County")).SendKeys(str23); new SelectElement( driver.FindElement( By.XPath("//div[@id='Contact.Address.CountryControl']/div/div/select"))) .SelectByText(str24); break; } driver.FindElement(By.Name("PostAction[Complete]")).Click(); Thread.Sleep(0x1388); if (Regex.IsMatch(str13, "^[0-9'']")) { _datarow.Newrow("Card Number", str13, str13, "PASS", driver); } else if (driver.PageSource.Contains("Number required") || driver.PageSource.Contains("Number invalid")) { _datarow.Newrow("Card Number", str13, "Number Invalid", "PASS", driver); } else { _datarow.Newrow("Card Number", str13, "No Error Message Displayed", "FAIL", driver); screenshot.Screenshotfailed(driver); } _datarow.Newrow("Card Type", expected, expected, "PASS", driver); var regex = new Regex("^[0-9]{3}$"); if (regex.IsMatch(str14)) { _datarow.Newrow("Security Code", str14, "Valid 3 Digits", "PASS", driver); } else if (driver.PageSource.Contains("Security code required") || driver.PageSource.Contains("Security code invalid")) { _datarow.Newrow("Security Code", str14, "Security code required", "PASS", driver ); } else { _datarow.Newrow("Security Code", str14, "No Error Message Displayed", "FAIL", driver ); screenshot.Screenshotfailed(driver); } if (Regex.IsMatch(str16, "^[a-zA-Z'']")) { _datarow.Newrow("Name on Card", str16, str16, "PASS", driver); } else if (driver.PageSource.Contains("Name required")) { _datarow.Newrow("Name on Card", str16, "Name Required", "PASS", driver); } else { _datarow.Newrow("Name on Card", str16, "No Error Message Displayed", "PASS", driver); screenshot.Screenshotfailed(driver); } if (Regex.IsMatch(input, "^[a-zA-Z'']")) { _datarow.Newrow("First Name", input, input, "PASS", driver); } else if (driver.PageSource.Contains("The First Name field is required.")) { _datarow.Newrow("First Name", input, "The First Name field is required.", "PASS", driver ); } else { _datarow.Newrow("First Name", input, "No Error Message Displayed", "FAIL", driver); screenshot.Screenshotfailed(driver); } if (Regex.IsMatch(str12, "^[a-zA-Z'']")) { _datarow.Newrow("Last Name", str12, str12, "PASS", driver); } else if (driver.PageSource.Contains("The Last Name field is required.")) { _datarow.Newrow("Last Name", str12, "The Last Name field is required.", "PASS", driver ); } else { _datarow.Newrow("Last Name", str12, "No Error message Displayed", "FAIL", driver); screenshot.Screenshotfailed(driver); } if (Regex.IsMatch(str20, "^[a-zA-Z0-9'']")) { _datarow.Newrow("Address", str20, str20, "PASS", driver); } else if (driver.PageSource.Contains("The Address field is required")) { _datarow.Newrow("Address", str20, "The Address field is required", "PASS", driver); } else { _datarow.Newrow("Address", str20, "No Error message Displayed", "FAIL", driver); screenshot.Screenshotfailed(driver); } if (Regex.IsMatch(str22, "^[a-zA-Z0-9'']")) { _datarow.Newrow("Post Code", str22, str22, "PASS", driver); } else if (driver.PageSource.Contains("The Postcode field is required")) { _datarow.Newrow("Post Code", str22, "The Postcode field is required.", "PASS", driver ); } else { _datarow.Newrow("Post Code", str22, "No Error Message Displayed", "FAIL", driver); screenshot.Screenshotfailed(driver); } if (Regex.IsMatch(str24, "^[a-zA-Z'']")) { _datarow.Newrow("Country", str24, str24, "PASS", driver); } else if (driver.PageSource.Contains("The Country field is required.")) { _datarow.Newrow("Country", str24, "The Country field is required.", "PASS", driver); } else { _datarow.Newrow("Country", str24, "No Error Message", "FAIL", driver); screenshot.Screenshotfailed(driver); } var title = driver.Title; if (title == "Secure Payment Page") continue; if (title == "Redirect to External") { Dsecure(driver); break; } if (driver.PageSource.Contains("Checkout Accepted")) { Normaltransaction(driver); break; } if (!driver.PageSource.Contains("Checkout Declined") && !driver.PageSource.Contains("Checkout Error")) continue; _datarow.Newrow("Checkout", "Checkout Declined", "Checkout Declined", "PASS", driver ); driver.FindElement(By.LinkText("start again")).Click(); break; } } } catch (Exception exception2) { Console.Write(exception2); var actual = exception2.ToString(); var screenshot2 = new Screenshot(); _datarow.Newrow("Checkout", "Server Error", actual, "FAIL", driver); screenshot2.Screenshotfailed(driver); } finally { new Screenshot().Screenshotnotifications(driver); _datarow.Excelsave("MoPayReport", driver, "*****@*****.**"); driver.Quit(); } }
public void Batchmoshop(IWebDriver driver, Datarow datarow, string items, string vers) { var screenshot = new Screenshot(); try { var moshop = new MoShopConsole(); moshop.Homepagetabs(driver, datarow); driver.Manage().Window.Maximize(); var strArray = items.Split(new[] {','}); foreach (var str in strArray.Where(str => str.Length != 0)) { #region Test Shop if (str == "Create a Test Shop") { datarow.Newrow("", "", "Create a Test Shop", "", driver); var testshop = new CreateShop(); testshop.Testshop(driver, datarow); new LookandFeel().Lookandfeel(driver, datarow); #region Global Settings new GlobalSetting(); // global.globalsetting(driver); #endregion } #endregion #region Test Scrape if (str == "Create a Test Scrape") { datarow.Newrow("", "", "Create a Test Scarpe", "", driver); new Createscrape().CreateScrape(driver, datarow); } #endregion #region Run Manual Scrape if (str == "Run Manual Scrape") { datarow.Newrow("", "", "Run Manual Scrape", "", driver); var run = new RunScrape(); run.Runscrape(driver, datarow); } #endregion #region Custom Domain Name Feature and Localisation if (str == "Validate Custom Domain Name Feature and Localisation") { datarow.Newrow("", "", "Validate Custom domain Name", "", driver); new Shop().Culture(driver, datarow); } #endregion #region "Run the Test Site - Scrape if (str == "Run the Test Site - Scrape") { try { driver.Manage().Window.Size = new Size(400, 550); datarow.Newrow("", "", "Run the Test Site", "", driver); driver.Navigate().GoToUrl("http://testshop.mobankdev.com/"); new BlobStorage(); //blob.Blob(driver,datarow, "http://testshop.mobankdev.com/"); commtest(driver, datarow); } catch (Exception ex) { var e = ex.ToString(); datarow.Newrow("Exception", "Exception Not Expected", e, "FAIL", driver); } } #endregion #region Run the Test Site - DataFeed XML if (str == "Run the Test Site - DataFeed XML") { var datafeed = new DatafeedXml(); datafeed.Datafeed(driver, datarow); datarow.Newrow("", "", "Run the Test Site-DataFeed", "", driver); driver.Navigate().GoToUrl("http://testshop.mobankdev.com/"); datarow.Newrow("", "", "Footer Links", "", driver); var footer = new FooterTps(); footer.Footerhome(driver, "http://testshop.mobankdev.com/", datarow); var relatedproduct = new RelatedProducts(); relatedproduct.Relatedproducts(driver, datarow); //commtest(driver, datarow); } #endregion #region Validate Products Against Live Site - Modropenia if (str == "Validate Products Against Live Site - Modropenia") { var modrophenia = new Modrophenialive(); modrophenia.modrophenialiveproducts(driver); var products = new Modropheniaproducts(); products.Product(datarow, driver); } #endregion # region Delete Shop And Scrape if (str != "Delete TestShop And TestScrape") continue; var delete = new DeleteTestShop(); delete.Deleteshop(driver); delete.Deletedscrape(driver); } #endregion Methods } catch(Exception exception) { var str2 = exception.ToString(); datarow.Newrow("Exception", "Exception Not Expected", str2, "FAIL", driver); screenshot.Screenshotfailed(driver); } finally { datarow.Excelsave("MoshopConsole", driver, "*****@*****.**"); screenshot.Screenshotfailed(driver); driver.Quit(); } }
public void Acctabs(IWebDriver driver, Datarow datarow) { driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management"); try { string str; driver.FindElement(By.CssSelector("#IndexMenu > ul > li.selected > ul > li > a")).Click(); if (driver.PageSource.Contains("Test Client Account")) { driver.FindElement(By.LinkText("Test Client Account")).Click(); datarow.Newrow("Test Client Tab", "Test Client Tab", "Test Client Account", "PASS", driver); } if (driver.PageSource.Contains("Test Client Account")) { driver.FindElement(By.LinkText("Test Client Account")).Click(); datarow.Newrow("Test Client Tab", "Test Client Tab", "Test Client Account", "PASS", driver); } else { str = "Test Client Account TabNot Present"; datarow.Newrow("Test Client Account Link", str, "Test Client Account Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var actual = driver.Title; if (actual == "Details : mopowered.co.uk") { datarow.Newrow("Details Tab", "Details : mopowered.co.uk", actual, "PASS", driver); } else { datarow.Newrow("Details Tab", "Details : mopowered.co.uk", actual, "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } if (driver.PageSource.Contains("Payment Provider")) { driver.FindElement(By.LinkText("Payment Provider")).Click(); datarow.Newrow("Payment Provider Tab", "Payment Provider Tab", "Payment Provider", "PASS", driver ); } else { str = "Payment Provider TabNot Present"; datarow.Newrow("Payment Provider Link", str, "Payment Provider Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var str3 = driver.Title; if (str3 == "Payment Provider : mopowered.co.uk") { datarow.Newrow("Payment Provider Tab", "Payment Provider : mopowered.co.uk", str3, "PASS", driver ); new Paymentprovider().Provider(driver, datarow); } else { datarow.Newrow("Payment Provider Tab", "Payment Provider : mopowered.co.uk", str3, "FAIL", driver ); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } if (driver.PageSource.Contains("Notifications")) { driver.FindElement(By.LinkText("Notifications")).Click(); datarow.Newrow("Notifications Tab", "Notifications Tab", "Notifications", "PASS", driver); new Notificationtab().Notifications(driver, datarow); } else { datarow.Newrow("Notifications Link", "Notifications TabNot Present", "Notifications Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var str4 = driver.Title; if (str4 == "Notifications : mopowered.co.uk") { datarow.Newrow("Notifications Tab", "Notifications : mopowered.co.uk", str4, "PASS", driver ); } else { datarow.Newrow("Notifications Tab", "Notifications : mopowered.co.uk", str4, "FAIL", driver ); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } Thread.Sleep(0x1388); if (driver.PageSource.Contains("Transactions")) { driver.FindElement(By.LinkText("Transactions")).Click(); datarow.Newrow("Transactions Tab", "Transactions Tab", "Transactions", "PASS", driver); } else { str = "Transactions TabNot Present"; datarow.Newrow("Transactions Link", str, "Transactions Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var str5 = driver.Title; if (str5 == "Transactions : mopowered.co.uk") { datarow.Newrow("Transactions Tab", "Transactions : mopowered.co.uk", str5, "PASS", driver); } else { datarow.Newrow("Transactions Tab", "Transactions : mopowered.co.uk", str5, "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } if (driver.PageSource.Contains("History")) { driver.FindElement(By.LinkText("History")).Click(); datarow.Newrow("History Tab", "History Tab", "History", "PASS", driver); } else { str = "History TabNot Present"; datarow.Newrow("History Link", str, "History Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var str6 = driver.Title; if (str6 == "History : mopowered.co.uk") { datarow.Newrow("History Tab", "History : mopowered.co.uk", str6, "PASS", driver); } else { datarow.Newrow("History Tab", "History : mopowered.co.uk", str6, "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0)); driver.FindElement(By.LinkText("Payment Provider")); driver.FindElement(By.LinkText("Payment Provider")).Click(); var str7 = driver.Title; if (str7 == "Payment Provider : mopowered.co.uk") { datarow.Newrow("Payment Provider Tab", "Payment Provider : mopowered.co.uk", str7, "PASS", driver ); } else { datarow.Newrow("Payment Provider Tab", "Payment Provider : mopowered.co.uk", str7, "FAIL", driver ); _screenshot.Screenshotfailed(driver); } if (driver.PageSource.Contains("…")) { driver.FindElement(By.LinkText("…")).Click(); datarow.Newrow("Update Tab", "Update Tab", "Update", "PASS", driver); } else { str = "Update TabNot Present"; datarow.Newrow("Update Link", str, "Update Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var str8 = driver.Title; if (str8 == "Update : mopowered.co.uk") { datarow.Newrow("Update Tab", "Update : mopowered.co.uk", str8, "PASS", driver); } else { datarow.Newrow("Update Tab", "Update : mopowered.co.uk", str8, "FAIL", driver); _screenshot.Screenshotfailed(driver); } var str9 = driver.Title; if (str9 == "Update : mopowered.co.uk") { datarow.Newrow("Update Tab", "Update : mopowered.co.uk", str9, "PASS", driver); } else { datarow.Newrow("Update Tab", "Update : mopowered.co.uk", str9, "FAIL", driver); _screenshot.Screenshotfailed(driver); } driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management"); if (driver.PageSource.Contains("Users")) { driver.FindElement(By.LinkText("Users")).Click(); datarow.Newrow("Users Tab", "Users Tab", "Users", "PASS", driver); } else { str = "Users TabNot Present"; datarow.Newrow("Users Link", str, "Users Link", "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } var str10 = driver.Title; if (str10 == "Users : mopowered.co.uk") { datarow.Newrow("Users Tab", "Users : mopowered.co.uk", str10, "PASS", driver); } else { datarow.Newrow("Users Tab", "Users : mopowered.co.uk", str10, "FAIL", driver); _screenshot.Screenshotfailed(driver); driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management/Accounts/Update/1"); } } catch (Exception exception) { var str11 = exception.ToString(); Console.Write(exception); datarow.Newrow("Exception", "Exception Not Expected", str11, "FAIL", driver); } finally { _screenshot.Screenshotfailed(driver); datarow.Excelsave("MopayConsole", driver, "*****@*****.**"); driver.Quit(); } }
public static void QuitDriver(IWebDriver driver) { driver.Quit(); }
public void Batchtesting(string items, string url, IWebDriver driver, Datarow datarow) { try { new BlobStorage(); // blob.Blob(driver,datarow, url); //string[] vesion = verson.Split(','); //foreach (string vsion in vesion) //{ // public const string version = vsion; //} var selectedvalue = items.Split(','); var i = 0; foreach (var function in selectedvalue) { if (function == "Search") { datarow.Newrow("", "", "Search", "", driver); new Searchsort().Search(driver); } if (function == "Test All Links in Mosite") { datarow.Newrow("", "", "All Links in Mosite - Validations", "", driver); var hom = new LinksTps(); hom.Links(datarow, driver, url); i++; } if (function == "Test Footer Links") { datarow.Newrow("", "", "Footer Links", "", driver); var footer = new FooterTps(); footer.Footerhome(driver, url, datarow); i++; } if (function == "Test Basket Functionality") { datarow.Newrow("", "", "Basket Functionality", "", driver); var basket = new BasketsTps(); basket.Basket(driver, datarow, url); i++; } if (function == "Test Product page - Test Add Product to Basket") { datarow.Newrow("", "", "User Journey", "", driver); var userjour = new UserJourneyTps(); userjour.UserJourn(datarow, driver, url); i++; } if (function == "Test Delete From Basket - Test product Unavailable") { datarow.Newrow("", "", "Delete From Basket", "", driver); var delete = new Deletebasketstart(); delete.Deletebasstart(driver, datarow); i++; } if (function == "Custom Checkout") { var ckout = new BatchCheckout(); ckout.Checkout(driver, url, datarow); } if (function == "Test Registration/Login - CheckOut Pages") { datarow.Newrow("", "", "Registration/Login", "", driver); var login = new LoginRegistration(); login.Registration(driver, datarow); i++; } if (function != "Test Mopay") continue; try { datarow.Newrow("", "", "Mopay", "", driver); var pay = new BatchPay(); pay.Batchpay(driver, url, datarow); } catch (Exception) { datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver); _screenshot.Screenshotfailed(driver); } i++; } } catch (Exception) { datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver); _screenshot.Screenshotfailed(driver); } finally { datarow.Excelsave("Mosite", driver, "*****@*****.**"); _screenshot.Screenshotfailed(driver); driver.Quit(); } }
void videos(IWebDriver driver) { bool clicked = false; while (true) { try { System.Collections.ObjectModel.ReadOnlyCollection<string> MorewindowHandles = driver.WindowHandles; foreach (String window in MorewindowHandles) { try { IWebDriver popup = driver.SwitchTo().Window(window); } catch { } try { if (driver.Title.Contains("Facebook")) { driver.Close(); } } catch { } try { driver.SwitchTo().DefaultContent(); Helpers.ByClass(driver, "jw-icon"); try { driver.FindElement(By.Id("tvStillTherePopupContinue")).Click(); } catch { } if (!clicked) { IList<IWebElement> offerButtons = driver.FindElements(By.ClassName("offerButton")); int counter = 0; foreach (IWebElement offerButton in offerButtons) { if (counter > 1) { offerButton.Click(); break; } counter++; } } } catch { try { driver.FindElement(By.LinkText("Earn Now")).Click(); } catch { } } Helpers.switchFrameByNumber(driver, 0); try { IList<IWebElement> oLinks = driver.FindElements(By.ClassName("singleselectset_radio")); Random random = new Random(); int rndClick = random.Next(1, oLinks.Count); Console.WriteLine(rndClick); int counterClick = 1; foreach (IWebElement oLink in oLinks) { Console.WriteLine(counterClick); if (counterClick == rndClick) { oLink.Click(); } counterClick++; } } catch { } try { IWebElement dropDownMonth = driver.FindElement(By.Id("dob_month")); IWebElement dropDownDay = driver.FindElement(By.Id("dob_day")); IWebElement dropDownYear = driver.FindElement(By.Id("dob_year")); string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; Random random = new Random(); int rndMonth = random.Next(0, 11); Console.WriteLine(rndMonth); SelectElement clickThis = new SelectElement(dropDownMonth); clickThis.SelectByText(months[rndMonth]); Helpers.wait(1000); int rndDay = random.Next(1, 28); clickThis = new SelectElement(dropDownDay); clickThis.SelectByText(rndDay.ToString()); Helpers.wait(1000); int rndYear = random.Next(1974, 1994); clickThis = new SelectElement(dropDownYear); clickThis.SelectByText(rndYear.ToString()); Helpers.wait(1000); } catch { } try { driver.FindElement(By.Id("demosubmitimg")).Click(); } catch { } try { Helpers.switchToBrowserByString(driver, "for E-Mail"); Helpers.switchFrameByNumber(driver, 0); if (Helpers.isClass(driver, "video-poster-play-icon")) { Helpers.ByClass(driver, "video-poster-play-icon"); clicked = true; } } catch { } Helpers.ByClass(driver, "video-poster-play-icon"); try { /* Actions builder = new Actions(driver); Helpers.wait(1000); IWebElement vidLink = driver.FindElement(By.ClassName("engagement")); Helpers.wait(1000); builder.MoveToElement(vidLink).Build().Perform(); //vidLink.Click(); */ if (driver.FindElement(By.ClassName("engagement")).Displayed) { driver.Quit(); } } catch { } try { IList<IWebElement> choices = driver.FindElements(By.ClassName("button")); foreach (IWebElement choice in choices) { choice.Click(); } } catch { } try { Helpers.switchToBrowserByString(driver, "Cash Videos - Earn Money Watching"); if (driver.FindElement(By.Id("adk_inter_cnt")).Text == "00:00") { driver.FindElement(By.Id("adk_inter_close")).Click(); Helpers.wait(5000); Helpers.ByClass(driver, "videos"); Helpers.closeWindows(driver, titles); clicked = false; } else if (driver.FindElement(By.Id("adk_inter_cnt")).Text == "01:30") { Helpers.closeWindows(driver, titles); Helpers.wait(5000); driver.FindElement(By.Id("adk_inter_close")).Click(); } } catch { } try { Helpers.switchFrameByNumber(driver, 0); driver.FindElement(By.ClassName("hd-container-header-action")).Click(); } catch { } try { driver.SwitchTo().DefaultContent(); driver.SwitchTo().Frame(driver.FindElement(By.CssSelector("div#social_videos_content iframe"))); if (driver.FindElement(By.Id("compositor_placed_innerclip_cta")).Displayed) { driver.SwitchTo().DefaultContent(); Helpers.ById(driver, "jungroupSubmit"); } } catch { } try { Helpers.switchFrameByNumber(driver, 0); try { driver.FindElement(By.ClassName("icon-close")).Click(); } catch { } Helpers.switchFrameByNumber(driver, 0); Helpers.switchFrameByNumber(driver, 0); Helpers.switchFrameByNumber(driver, 0); driver.FindElement(By.ClassName("ytp-large-play-button")).Click(); } catch { } Helpers.wait(5000); } clicked = Helpers.lookFor(driver, "for E-Mail"); if (Helpers.lookFor(driver, "Entertainmentcrave.com")) { encrave(driver); } } catch { } } }
private void __DismissDriver(IWebDriver driver) { if (!driverToKeyMap.ContainsKey(driver)) { throw new Exception("The driver is not owned by the factory: " + driver); } if (driver != threadLocalDriver.Value) { throw new Exception("The driver does not belong to the current thread: " + driver); } driver.Quit(); driverToKeyMap.Remove(driver); threadLocalDriver.Dispose(); }
public void TheCandidateTestJavascriptDisabled() { Random gen = new Random(); FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("javascript.enabled", false); driver = new FirefoxDriver(profile); verificationErrors = new StringBuilder(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); driver.Navigate().GoToUrl("http://test.telerikacademy.com/SoftwareAcademy/Candidate"); driver.FindElement(By.Id("UsernameOrEmail")).Clear(); driver.FindElement(By.Id("UsernameOrEmail")).SendKeys("qaacademy2013"); driver.FindElement(By.Id("Password")).Clear(); driver.FindElement(By.Id("Password")).SendKeys("qastudent"); driver.FindElement(By.CssSelector("input.submit-button")).Click(); driver.FindElement(By.Id("FirstName")).Clear(); driver.FindElement(By.Id("FirstName")).SendKeys("QA"); driver.FindElement(By.Id("SecondName")).Clear(); driver.FindElement(By.Id("SecondName")).SendKeys("QA"); driver.FindElement(By.Id("LastName")).Clear(); driver.FindElement(By.Id("LastName")).SendKeys("QA"); driver.FindElement(By.CssSelector("input#BirthDay.date-picker")).Clear(); driver.FindElement(By.CssSelector("input#BirthDay.date-picker")).SendKeys("01/01/1900"); driver.FindElement(By.Id("SchoolName")).Click(); driver.FindElement(By.Id("SchoolName")).Clear(); driver.FindElement(By.Id("SchoolName")).SendKeys("mySchool"); driver.FindElement(By.Id("Email")).Clear(); driver.FindElement(By.Id("Email")).SendKeys(""); driver.FindElement(By.Id("Phone")).Clear(); driver.FindElement(By.Id("Phone")).SendKeys("0888123456"); driver.FindElement(By.Id("SendButton")).Click(); try { Assert.IsTrue(IsElementPresent(By.CssSelector("span.field-validation-error > span"))); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } driver.FindElement(By.Id("Email")).Click(); string email = "qastudent" + gen.Next(1, 100000) + "@abv.bg"; driver.FindElement(By.Id("Email")).Click(); driver.FindElement(By.Id("Email")).SendKeys(email); driver.Manage().Cookies.DeleteCookieNamed("ASPXAUTH"); try { Assert.IsTrue(Regex.IsMatch(driver.FindElement(By.Id("Email")).Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$")); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } try { Assert.IsTrue(!IsElementPresent(By.CssSelector("span.field-validation-error > span"))); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } try { Assert.IsFalse(Regex.IsMatch(driver.FindElement(By.CssSelector("BODY")).Text, "^[\\s\\S]*Имейл адресът е задължителен\\.[\\s\\S]*$")); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } driver.FindElement(By.Id("Email")).Clear(); driver.FindElement(By.Id("Email")).SendKeys("abv.bg"); try { Assert.AreEqual("Моля въведете валиден e-mail адрес.", driver.FindElement(By.XPath("//fieldset[@id='PersonalData']/div[12]/span")).Text); } catch (AssertFailedException e) { verificationErrors.Append(e.Message); } driver.FindElement(By.Id("ExitMI")).Click(); driver.Close(); driver.Quit(); }
public void FireFoxTestMethod() { try { driver = new FirefoxDriver(); driver.Navigate().GoToUrl(baseURL + "/slider/"); TestJQuerySlider(driver); } catch (Exception ex) { Console.Write(ex.Message); throw ex; } finally { if (driver != null) { driver.Quit(); driver = null; } } }