public static string GetBrowserName() { if (type.ToString() == "Chrome" || type.ToString() == "Firefox") { return(type.ToString()); } else { return(ConfigManager.ConfigBrowser); } }
public override string ToString() { System.Text.StringBuilder builder = new System.Text.StringBuilder(100); builder.Append("FullName="); builder.Append(FullName); builder.Append("|UserName="******"|UserID="); builder.Append(UserID); builder.Append("|UserType="); builder.Append(UserType); builder.Append("|IP="); builder.Append(IP); builder.Append("|HTTP_USER_AGENT="); builder.Append(HTTP_USER_AGENT); builder.Append("|HTTP_HOST="); builder.Append(HTTP_HOST); builder.Append("|Browser="); builder.Append(Browser.ToString()); builder.Append("|UserGroupID="); builder.Append(UserGroupID); return(builder.ToString()); }
public Browser(BrowserType browser, BrowserSize windowSize) { switch (browser) { case BrowserType.Firefox: webDriver = new FirefoxDriver(); break; case BrowserType.Chrome: webDriver = new ChromeDriver(); break; case BrowserType.IE: webDriver = new OpenQA.Selenium.IE.InternetExplorerDriver(); break; default: throw new DriverServiceNotFoundException($"{browser.ToString()} not supported in this testing suite"); } if (windowSize == BrowserSize.Maximize) { webDriver.Manage().Window.Maximize(); } else { //browser window size format: whatevername_widthxheight //example Desktop_1524x768 string[] browserSize = windowSize.ToString().Split('_')[1].Split('x'); webDriver.Manage().Window.Size = new System.Drawing.Size(int.Parse(browserSize[0]), int.Parse(browserSize[1])); } }
private void ResizeWindow() { bool endProcess = false; // max wait is 5 sec. of process int maxCountCycle = 10; for (int i = 0; i < maxCountCycle; i++) { Process[] processes = Process.GetProcessesByName(type.ToString().ToLower()); foreach (var process in processes.Where(p => p.MainWindowHandle != IntPtr.Zero)) { if ((process.MainWindowTitle.Contains(loginHeader) || process.MainWindowTitle.Contains(authorizeHeader)) && process.MainWindowTitle.Contains(fluxHeader)) { NewWindowHWND = process.MainWindowHandle; ShowWindow(process.MainWindowHandle, 1); //SW_SHOWNORMAL RECT rectangle; GetWindowRect(process.MainWindowHandle, out rectangle); SetWindowPos(process.MainWindowHandle, 0, rectangle.Left, rectangle.Top, width, height, 0x0040); //SWP_SHOWWINDOW Displays the window. endProcess = true; } } if (endProcess) { break; } Thread.Sleep(500); } }
private void LogTestDetails(string[] testDetails) { string _suite = testDetails[0]; string _priority = testDetails[1]; string _tcNumber = testDetails[2]; string _component1 = testDetails[3]; string _component2 = testDetails[4]; string _testEnv = testDetails[5]; string _tenantName = testDetails[6]; string components = !_component2.HasValue() ? $": {_component1}" : $"s: {_component1}, {_component2}"; log.Info($"################################################################"); log.Info($"# RKCI ELVIS UI Test Automation"); log.Info($"################################################################"); log.Info($"# -->> Test Configuration <<--"); log.Info($"# Tenant: {_tenantName} TestEnv: {_testEnv}"); log.Info($"# Site URL: {siteUrl}"); log.Info($"# Browser: {browserType.ToString()}"); log.Info($"#"); log.Info($"# -->> Test Case Details <<--"); log.Info($"# Name: {testName}"); log.Info($"# Description: {testDescription}"); log.Info($"# TC#: {_tcNumber}, {_priority}"); log.Info($"# Suite: {_suite}, Component{components}"); log.Info($"# Date & Time: {DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}"); log.Info($"################################################################\n"); }
public void should_be_able_to_fill_sample_form(BrowserType driverType) { //Initialize MvcPages var browserAdapterConfig = new BrowserAdapterConfig() { BrowserType = driverType, SeleniumDriversPath = TestContext.CurrentContext.TestDirectory, PageUrl = "http://*****:*****@"c:\selenium\", BrowserDimensions = new BrowserDimensionsConfig { Width = 1200, Height = 768 }, BrowserCameraConfig = new BrowserCameraConfig { LensType = LensType.Regular } }; //Initialize VisualAssertions AssertView.Init(new VisualAssertionsConfig { BrowserName = driverType.ToString(), ProjectName = "Sample Project", ScreenshotCategory = "Sample Form", }); //Prepare infrastructure for test using (var browserAdapter = BrowserAdapter.Create(browserAdapterConfig)) { //Test browserAdapter.NavigateTo <TestFormsController>(c => c.Index()); AssertView.EqualsToPattern(browserAdapter, "Sample1"); var detinationForm = browserAdapter.GetForm <SampleFormViewModel>(FormsIds.TestFormDst); var sourcenForm = browserAdapter.GetForm <SampleFormViewModel>(FormsIds.TestFormSrc); var textInputValue = sourcenForm.GetFieldValue(x => x.TextInput); detinationForm.SetFieldValue(x => x.TextInput, textInputValue); var textAreaValue = sourcenForm.GetFieldValue(x => x.TextAreaInput); detinationForm.SetFieldValue(x => x.TextAreaInput, textAreaValue); var passwordValue = sourcenForm.GetFieldValue(x => x.PasswordInput); detinationForm.SetFieldValue(x => x.PasswordInput, passwordValue); var checkboxValue = sourcenForm.GetFieldValue(x => x.CheckboxInput); detinationForm.SetFieldValue(x => x.CheckboxInput, checkboxValue); var selectListValue = sourcenForm.GetFieldValue(x => x.SelectListValue); detinationForm.SetFieldValue(x => x.SelectListValue, selectListValue); AssertView.EqualsToPattern(browserAdapter, "Sample2"); } }
public static ICapabilities getDriverCapabilities(BrowserType browser) { foreach (Driver driver in config.drivers) { if (driver.name.ToUpper().Equals(browser.ToString().ToUpper())) { return(CreateCapabilities(driver)); } } return(new DesiredCapabilities()); }
internal IWebDriver CreateBrowser(Network type, BrowserType name) { return(type switch { Network.Local => (name switch { BrowserType.Chrome => GetChromeDriver(), BrowserType.Edge => new EdgeDriver(), BrowserType.Firefox => GetFirefoxDriver(), _ => throw new ArgumentOutOfRangeException(name.ToString(), $"No such browser {name.ToString()}") }),
private IWebDriver OpenBrowser(BrowserType browserType) { _testOutputHelper.WriteLine($" Opening browser {browserType.ToString()}"); IWebDriver driver = null; switch (browserType) { case BrowserType.Chrome: { driver = new ChromeDriver(); break; } case BrowserType.FireFox: { driver = new FirefoxDriver(); break; } case BrowserType.InternetExplorer: { driver = new InternetExplorerDriver(); break; } } if (driver == null) { throw new Exception($"Wrong browser type passed `{browserType.ToString()}`"); } driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15); driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(15); driver.Manage().Window.Maximize(); return(driver); }
public void InitializeTest() { ObjectRepository.config = new ConfigReader(); BrowserType browser = ObjectRepository.config.GetBrowserName(); switch (browser) { case BrowserType.Chrome: ObjectRepository.driver = GetChromedriver(); break; default: throw new CustomException(browser.ToString() + " " + "browser is not found"); } }
public void CreateSession(BrowserType browserType) { switch (browserType) { case (BrowserType.CHROME): { webDriver = BuildChromeDriver(); break; } default: throw new NotSupportedException( string.Format("The browser type {0} is not supported.", browserType.ToString())); } }
/// <inheritdoc /> public BrowserAbstract AcquireBrowser(BrowserType browserType) { var browserManager = ObjectResolver.Resolve <IBrowserManager>(); // there is no browser pool created if (browserManager.AvailableBrowserTypes.All(t => t != browserType)) { throw new ArgumentException( $"There is no browser pool created for type {browserType}.", browserType.ToString()); } // try to acquire a browser BrowserAbstract browser = browserManager.AcquireBrowser(browserType); if (browser == null) { throw new ArgumentException( "Browser type {0} not available.".FormatIc(browserType.ToString()), browserType.ToString()); } return(browser); }
public void WriteXml(XmlWriter writer) { //Write start of main elemenst writer.WriteStartElement("portalAlias"); //write out properties writer.WriteElementString("portalID", PortalID.ToString()); writer.WriteElementString("portalAliasID", PortalAliasID.ToString()); writer.WriteElementString("HTTPAlias", HTTPAlias); writer.WriteElementString("skin", Skin); writer.WriteElementString("cultureCode", CultureCode); writer.WriteElementString("browserType", BrowserType.ToString().ToLowerInvariant()); writer.WriteElementString("primary", IsPrimary.ToString().ToLowerInvariant()); //Write end of main element writer.WriteEndElement(); }
public void Start(BrowserType browser, bool remote = false, DriverOptions options = null, string version = null, string url = null, PlatformType platform = PlatformType.Any) { if (!(WebDriver is null)) { return; } if (remote) { if ((version is null) || (url is null)) { return; } switch (browser) { case BrowserType.Chrome: case BrowserType.Mozila: { #pragma warning disable 618 var capabilities = new DesiredCapabilities(browser.ToString().ToLower(), version, new Platform(platform)); capabilities?.SetCapability("enableVNC", true); #pragma warning restore 618 WebDriver = new RemoteWebDriver(new Uri(url), capabilities); return; } default: throw new ArgumentOutOfRangeException(nameof(browser), browser, null); } } switch (browser) { case BrowserType.Chrome: case BrowserType.Mozila: Start(browser, options); break; default: throw new ArgumentOutOfRangeException(nameof(browser), browser, null); } }
private RemoteWebDriver GetAuthenticatedDriver(BrowserType browserType, String browserMobPath, String domain, String username, String password) { if (browserType.Equals(BrowserType.Firefox)) { return(GetModifiedFirefoxDriver(browserMobPath, domain, username, password)); } else if (browserType.Equals(BrowserType.IE)) { return(GetModifiedIEDriver(browserMobPath, domain, username, password)); } else if (browserType.Equals(BrowserType.Chrome)) { return(GetModifiedChromeDriver(browserMobPath, domain, username, password)); } else { throw new Exception("BrowserType: " + browserType.ToString() + " not supported"); } }
public static IWebDriver GetWebDriver(BrowserType browserType, string dowloadDirectory = @"C:\Downloads") { switch (browserType) { case BrowserType.Chrome: ChromeOptions options = new ChromeOptions(); options.AddUserProfilePreference("download.default_directory", dowloadDirectory); return(new ChromeDriver(options)); case BrowserType.Firefox: var profile = new FirefoxOptions(); profile.SetPreference("browser.download.manager.showWhenStarting", false); profile.SetPreference("browser.download.manager.showAlertOnComplete", false); profile.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip"); profile.SetPreference("browser.download.folderList", 2); profile.SetPreference("browser.download.dir", dowloadDirectory); return(new FirefoxDriver(profile)); default: throw new Exception(browserType.ToString() + " Browser Type isn't implemented"); } }
public static IWebDriver MakeDriver(BrowserType type) { switch (type) { case BrowserType.Chrome: { if (_driver == null) { _driver = new ChromeDriver(); return(_driver); } return(_driver); } case BrowserType.Firefox: { if (_driver == null) { _driver = new FirefoxDriver(); return(_driver); } return(_driver); } case BrowserType.Edge: { if (_driver == null) { _driver = new EdgeDriver(); return(_driver); } return(_driver); } default: throw new Exception("Driver already instantiated as " + type.ToString()); } }
public static void SaveOptionsToXml() { using (var writer = new XmlTextWriter(optionsPath, new UTF8Encoding()) { Formatting = Formatting.Indented, Indentation = 4 }) { writer.WriteStartDocument(); writer.WriteComment(nameof(Browser) + " plugin options"); writer.WriteStartElement("Options"); { WriteOption(writer, nameof(BrowserType), BrowserType.ToString("G")); WriteOption(writer, nameof(LaunchAtStartup), LaunchAtStartup.ToString()); WriteOption(writer, nameof(LaunchHidden), LaunchHidden.ToString()); // WriteOption(writer, nameof(BrowserWindowX), BrowserWindowX.ToString()); WriteOption(writer, nameof(BrowserWindowY), BrowserWindowY.ToString()); WriteOption(writer, nameof(BrowserWindowW), BrowserWindowW.ToString()); WriteOption(writer, nameof(BrowserWindowH), BrowserWindowH.ToString()); } writer.WriteEndElement(); // options writer.WriteEndDocument(); } }
/// <summary> /// Opens the given browswer type with the given command timeout /// </summary> /// <param name="browser"></param> /// <param name="commandTimeout"></param> protected void OpenBrowser(BrowserType browser, TimeSpan commandTimeout) { LogMsg("OpenBrowser: browser: [" + browser.ToString() + "]"); const int MAX_RETRY_COUNT = 10; // We do progressive backoffs on subsequent attempts so we have // the back off factor a multiple of this value so be careful // to not make it too large const int RETRY_PAUSE_MILLISECONDS = 1000; // We do a sleep for (RETRY_PAUSE_MILLISECONDS + (retryCount * RETRY_BACKOFF_FACTOR * RETRY_PAUSE_MILLISECONDS)) const double RETRY_BACKOFF_FACTOR = 0.5; int retryCount = 0; bool done = false; // Loop until we can connect or we time out while (!done) { try { switch (browser) { case BrowserType.Firefox: _Driver = new FirefoxDriver(); break; case BrowserType.Chrome: ChromeOptions options = new ChromeOptions(); options.AddArgument("incognito"); _Driver = new ChromeDriver(_ChromeDriverPath, options, _SeleniumCommandTimeout); break; case BrowserType.IE: _Driver = new InternetExplorerDriver(); break; default: new Exception("Unhandled browser type given when opening a browser."); break; } // Did we get a driver? done = (_Driver != null); if (done) { _Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); } } catch (Exception ex) { LogMsg("OpenBrowser: An exception occurred opening a [" + browser.ToString() + "]. Here are the details: " + ex.ToString()); if ((ex.ToString().Contains("Unable to bind to locking port")) && (retryCount < MAX_RETRY_COUNT)) { LogMsg("Unable to bind to a locking port so we are going to retry a few times before giving up."); Thread.Sleep((int)(RETRY_PAUSE_MILLISECONDS + (retryCount * RETRY_BACKOFF_FACTOR * RETRY_PAUSE_MILLISECONDS))); retryCount++; } else { done = true; } } } }
public void ValidateProductListElement(List <IWebElement> productElements, BrowserType browserType, int width, int height, string deviceType, int i) { bool tempResult; IWebElement tempWebElement; int prodNumber = 1; foreach (var item in productElements) { //Validate the product image, name and price tag are displayed for both the products tempWebElement = item.FindElement(By.XPath(PLPage.productImageLocator)); tempResult = tempWebElement.Displayed; Utils.HackathonReport(i++, $"Shopping Experience Test - Display of image for product - {prodNumber}", tempWebElement.GetAttribute("id"), browserType.ToString(), width, height, deviceType, (tempResult ? "Pass" : "Fail"), fileName); tempWebElement = item.FindElement(By.XPath(PLPage.productNameLocator)); tempResult = tempWebElement.Displayed; Utils.HackathonReport(i++, $"Shopping Experience Test - Display of name for product - {prodNumber}", tempWebElement.GetAttribute("id"), browserType.ToString(), width, height, deviceType, (tempResult ? "Pass" : "Fail"), fileName); tempWebElement = item.FindElement(By.XPath(PLPage.productPriceLocator)); tempResult = tempWebElement.Displayed; Utils.HackathonReport(i++, $"Shopping Experience Test - Display of price for product - {prodNumber}", tempWebElement.GetAttribute("id"), browserType.ToString(), width, height, deviceType, (tempResult ? "Pass" : "Fail"), fileName); //Using actions class to hover the mouse on the product, which will display the add to favorite/cart/compare button if (deviceType.Equals("Laptop")) { MouseHoverAction(tempWebElement, driver); } //Validate the presence of tooltip - Add to Favorites, Add to Cart, Add to compare tempWebElement = item.FindElement(By.XPath(PLPage.addToFavoriteLocator)); tempResult = tempWebElement.Displayed; Utils.HackathonReport(i++, $"Shopping Experience Test - Display of Add to favorite tag - {prodNumber}", tempWebElement.GetAttribute("id"), browserType.ToString(), width, height, deviceType, (tempResult ? "Pass" : "Fail"), fileName); //Validate the presence of tooltip - Add to Favorites, Add to Cart, Add to compare tempWebElement = item.FindElement(By.XPath(PLPage.addToCartLocator)); tempResult = tempWebElement.Displayed; Utils.HackathonReport(i++, $"Shopping Experience Test - Display of Add to cart tag - {prodNumber}", tempWebElement.GetAttribute("id"), browserType.ToString(), width, height, deviceType, (tempResult ? "Pass" : "Fail"), fileName); //Validate the presence of tooltip - Add to Favorites, Add to Cart, Add to compare tempWebElement = item.FindElement(By.XPath(PLPage.addToCompareLocator)); tempResult = tempWebElement.Displayed; Utils.HackathonReport(i++, $"Shopping Experience Test - Display of Add to compare tag - {prodNumber}", tempWebElement.GetAttribute("id"), browserType.ToString(), width, height, deviceType, (tempResult ? "Pass" : "Fail"), fileName); prodNumber++; } FooterValidation(browserType, width, height, deviceType, "Shopping Experience Test", i); }
public void FooterValidation(BrowserType browserType, int width, int height, string deviceType, string testName, int i) { Console.WriteLine($"Task count for Footer validation for {testName} is {i}"); Utils.HackathonReport($"---------- Footer Validation for the test - {testName} in {deviceType} starts ---------- ", fileName); bool quickLinksHdrResult = driver.FindElementByXPath(HomePage.quickLinksHeader).Displayed; Utils.HackathonReport(i, $"{testName} - Footer Validation - Display of Quick Links Header", HomePage.quickLinksHeader, browserType.ToString(), width, height, deviceType, (quickLinksHdrResult ? "Pass" : "Fail"), fileName); if (deviceType.Equals("Tablet")) { driver.FindElementByXPath(HomePage.quickLinksHeader).Click(); } bool aboutUsResult = driver.FindElementByXPath(HomePage.aboutUs).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of About Us", HomePage.aboutUs, browserType.ToString(), width, height, deviceType, (aboutUsResult ? "Pass" : "Fail"), fileName); bool faqResult = driver.FindElementByXPath(HomePage.faq).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of FAQ", HomePage.faq, browserType.ToString(), width, height, deviceType, (faqResult ? "Pass" : "Fail"), fileName); bool helpResult = driver.FindElementByXPath(HomePage.help).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Help", HomePage.help, browserType.ToString(), width, height, deviceType, (helpResult ? "Pass" : "Fail"), fileName); bool myAccountResult = driver.FindElementByXPath(HomePage.myAccount).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of My Account", HomePage.myAccount, browserType.ToString(), width, height, deviceType, (myAccountResult ? "Pass" : "Fail"), fileName); bool blogResult = driver.FindElementByXPath(HomePage.blog).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Blog", HomePage.blog, browserType.ToString(), width, height, deviceType, (blogResult ? "Pass" : "Fail"), fileName); bool contactsResult = driver.FindElementByXPath(HomePage.contacts).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Contacts under Quick Links", HomePage.contacts, browserType.ToString(), width, height, deviceType, (contactsResult ? "Pass" : "Fail"), fileName); if (deviceType.Equals("Tablet")) { driver.FindElementByXPath(HomePage.quickLinksHeader).Click(); } InduceDelay(2); if (deviceType.Equals("Tablet")) { driver.FindElementByXPath(HomePage.contactsHeader).Click(); } bool contactHomeAddrResult = driver.FindElementByXPath(HomePage.contactsHomeAddress).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Contacts - Home Address", HomePage.contactsHomeAddress, browserType.ToString(), width, height, deviceType, (contactHomeAddrResult ? "Pass" : "Fail"), fileName); bool contactEmailAddrResult = driver.FindElementByXPath(HomePage.contactsEmailAddress).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Contacts - Email Address", HomePage.contactsEmailAddress, browserType.ToString(), width, height, deviceType, (contactEmailAddrResult ? "Pass" : "Fail"), fileName); if (deviceType.Equals("Tablet")) { driver.FindElementByXPath(HomePage.contactsHeader).Click(); } InduceDelay(2); if (deviceType.Equals("Tablet")) { driver.FindElementByXPath(HomePage.keepInTouchHeader).Click(); } bool keepInTouchHdrResult = driver.FindElementByXPath(HomePage.keepInTouchHeader).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Keep In Touch Header", HomePage.keepInTouchHeader, browserType.ToString(), width, height, deviceType, (keepInTouchHdrResult ? "Pass" : "Fail"), fileName); bool keepInTouchTxtBoxResult = driver.FindElementByXPath(HomePage.keepInTouchTextBox).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Keep In Touch Textbox", HomePage.keepInTouchTextBox, browserType.ToString(), width, height, deviceType, (keepInTouchTxtBoxResult ? "Pass" : "Fail"), fileName); bool keepInTouchSubmitBtnResult = driver.FindElementByXPath(HomePage.keepInTouchSubmitBtn).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Keep In Touch Submit button", HomePage.keepInTouchSubmitBtn, browserType.ToString(), width, height, deviceType, (keepInTouchSubmitBtnResult ? "Pass" : "Fail"), fileName); if (deviceType.Equals("Tablet")) { driver.FindElementByXPath(HomePage.keepInTouchHeader).Click(); } bool langSelectorResult = driver.FindElementByXPath(HomePage.languageLocator).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Language Selector", HomePage.languageLocator, browserType.ToString(), width, height, deviceType, (langSelectorResult ? "Pass" : "Fail"), fileName); bool currencySelectorResult = driver.FindElementByXPath(HomePage.currencySelectorLocator).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Currency Selector", HomePage.currencySelectorLocator, browserType.ToString(), width, height, deviceType, (currencySelectorResult ? "Pass" : "Fail"), fileName); bool termsAndCondnResult = driver.FindElementByXPath(HomePage.termsAndConditionLocator).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Terms and Conditions", HomePage.termsAndConditionLocator, browserType.ToString(), width, height, deviceType, (termsAndCondnResult ? "Pass" : "Fail"), fileName); bool privacyResult = driver.FindElementByXPath(HomePage.privacyLocator).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Privacy", HomePage.privacyLocator, browserType.ToString(), width, height, deviceType, (privacyResult ? "Pass" : "Fail"), fileName); bool trademarkResult = driver.FindElementByXPath(HomePage.trademarkLocator).Displayed; Utils.HackathonReport(i++, $"{testName} - Footer Validation - Display of Trademark", HomePage.trademarkLocator, browserType.ToString(), width, height, deviceType, (trademarkResult ? "Pass" : "Fail"), fileName); Utils.HackathonReport($"---------- Footer Validation for the test - {testName} in {deviceType} ends ---------- ", fileName); }
public void ElementDisplayInLaptopModeTest(BrowserType browserType, int width, int height) { Console.WriteLine($"Browser type - {browserType}, Width - {width}, Height - {height}"); string deviceType = "Laptop"; driver = OpenBrowser(browserType); driver.Url = appURL; Console.WriteLine(driver.Manage().Window.Size); driver.Manage().Window.Size = new System.Drawing.Size(width, height); Console.WriteLine(driver.Manage().Window.Size); Thread.Sleep(TimeSpan.FromSeconds(5)); //Display of top menu - Home, Men Women etc //Display of banner //Display of Search text box //Display of Filter panel on the left //Display of Wishlist image on top right //Display of view mode - grid (or) list mode //No Display of Filter symbol int i = 1; Utils.HackathonReport($"---------- Validation for Cross Device Element in LAPTOP mode starts ---------- ", fileName); bool topMenuResult = driver.FindElementByXPath(HomePage.topMenuList).Displayed; Utils.HackathonReport(i, "Cross Device Element Test - Display of Top Menu", HomePage.topMenuList, browserType.ToString(), width, height, deviceType, (topMenuResult ? "Pass" : "Fail"), fileName); bool searchTextBoxResult = driver.FindElementByXPath(HomePage.searchInputField).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - Display of Search text box", HomePage.searchInputField, browserType.ToString(), width, height, deviceType, (searchTextBoxResult ? "Pass" : "Fail"), fileName); bool filterPanelResult = driver.FindElementByXPath(HomePage.filterPanel).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - Display of Filter panel on the left", HomePage.filterPanel, browserType.ToString(), width, height, deviceType, (filterPanelResult ? "Pass" : "Fail"), fileName); bool wishlistImageResult = driver.FindElementByXPath(HomePage.wishListIcon).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - Display of Wishlist", HomePage.wishListIcon, browserType.ToString(), width, height, deviceType, (wishlistImageResult ? "Pass" : "Fail"), fileName); bool viewListResult = driver.FindElementByXPath(HomePage.viewList).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - Display of View Mode - List", HomePage.viewList, browserType.ToString(), width, height, deviceType, (viewListResult ? "Pass" : "Fail"), fileName); bool viewGridResult = driver.FindElementByXPath(HomePage.viewGrid).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - Display of View Mode - Grid", HomePage.viewGrid, browserType.ToString(), width, height, deviceType, (viewGridResult ? "Pass" : "Fail"), fileName); bool filterSymbolInTableModeResult = !driver.FindElementByXPath(HomePage.filtersAnchorInTabletMode).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - No Display of Filter symbol", HomePage.filtersAnchorInTabletMode, browserType.ToString(), width, height, deviceType, (filterSymbolInTableModeResult ? "Pass" : "Fail"), fileName); bool bannerDisplayResult = driver.FindElementByXPath(HomePage.bannerLocator).Displayed; Utils.HackathonReport(i++, "Cross Device Element Test - Display of Banner", HomePage.bannerLocator, browserType.ToString(), width, height, deviceType, (bannerDisplayResult ? "Pass" : "Fail"), fileName); FooterValidation(browserType, width, height, deviceType, "Cross Device Element Test", i); Utils.HackathonReport($"---------- Validation for Cross Device Element in LAPTOP mode ends ---------- ", fileName); Assert.IsTrue(topMenuResult && bannerDisplayResult && searchTextBoxResult && filterPanelResult && wishlistImageResult && viewListResult && viewGridResult && filterSymbolInTableModeResult); }
public void ValidateProductDetailsPage(BrowserType browserType, int width, int height, string deviceType) { //Validate the below points //Display of Product Name //Display of Product Image //Display of Product Rating //Display of Product Description //Display of Size label and Size dropdown //Display of Quantity label, Quantity text box //Display of Quantity increment and decrement buttons //Display of new price, old price and discount percentage //Display of Add to cart button int i = 1; bool nameResult = driver.FindElementByXPath(PDPage.h1Locator).Displayed; Utils.HackathonReport(i, "Product Details Test - Display of Product Name", PDPage.h1Locator, browserType.ToString(), width, height, deviceType, (nameResult ? "Pass" : "Fail"), fileName); bool imageResult = driver.FindElementByXPath(PDPage.shoeImageLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Product Image", PDPage.shoeImageLocator, browserType.ToString(), width, height, deviceType, (imageResult ? "Pass" : "Fail"), fileName); bool ratingResult = driver.FindElementByXPath(PDPage.ratingLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Product Rating", PDPage.ratingLocator, browserType.ToString(), width, height, deviceType, (ratingResult ? "Pass" : "Fail"), fileName); bool descriptionResult = driver.FindElementByXPath(PDPage.productDescriptionLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Product Description", PDPage.productDescriptionLocator, browserType.ToString(), width, height, deviceType, (descriptionResult ? "Pass" : "Fail"), fileName); bool sizeLabelResult = driver.FindElementByXPath(PDPage.sizeLabelLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Size label", PDPage.sizeLabelLocator, browserType.ToString(), width, height, deviceType, (sizeLabelResult ? "Pass" : "Fail"), fileName); //Click on the dropdown driver.FindElementByXPath(PDPage.sizeDropdownLocator).Click(); bool sizeDropdownResult = driver.FindElementByXPath(PDPage.sizeDropdownListLocator).Displayed; driver.FindElementByXPath(PDPage.sizeDropdownLocator).Click(); Utils.HackathonReport(i++, "Product Details Test - Display of Size Dropdown", PDPage.sizeDropdownListLocator, browserType.ToString(), width, height, deviceType, (sizeDropdownResult ? "Pass" : "Fail"), fileName); bool qtyLabelResult = driver.FindElementByXPath(PDPage.quantityLabelLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Quantity Label", PDPage.quantityLabelLocator, browserType.ToString(), width, height, deviceType, (qtyLabelResult ? "Pass" : "Fail"), fileName); bool qtyIncBtnResult = driver.FindElementByXPath(PDPage.quantityIncBtnLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Quantity Increment Button", PDPage.quantityLabelLocator, browserType.ToString(), width, height, deviceType, (qtyIncBtnResult ? "Pass" : "Fail"), fileName); bool qtyDecBtnResult = driver.FindElementByXPath(PDPage.quantityDecBtnLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Quantity Decrement Button", PDPage.quantityDecBtnLocator, browserType.ToString(), width, height, deviceType, (qtyDecBtnResult ? "Pass" : "Fail"), fileName); bool addToCartBtnResult = driver.FindElementByXPath(PDPage.addToCartAnchorLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Add To Cart Button", PDPage.addToCartAnchorLocator, browserType.ToString(), width, height, deviceType, (addToCartBtnResult ? "Pass" : "Fail"), fileName); bool newPriceResult = driver.FindElementByXPath(PDPage.newPriceLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of New Price", PDPage.newPriceLocator, browserType.ToString(), width, height, deviceType, (newPriceResult ? "Pass" : "Fail"), fileName); bool oldPriceResult = driver.FindElementByXPath(PDPage.oldPriceLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Old Price", PDPage.newPriceLocator, browserType.ToString(), width, height, deviceType, (oldPriceResult ? "Pass" : "Fail"), fileName); bool discountResult = driver.FindElementByXPath(PDPage.discountLocator).Displayed; Utils.HackathonReport(i++, "Product Details Test - Display of Discount", PDPage.newPriceLocator, browserType.ToString(), width, height, deviceType, (discountResult ? "Pass" : "Fail"), fileName); FooterValidation(browserType, width, height, deviceType, "Product Details Test", i); }
public void StartBrowser(BrowserType browser, string[] driverOptions = null, string configurationPath = null) { switch (browser) { case BrowserType.Chrome: RunChrome(configurationPath, driverOptions); break; case BrowserType.Firefox: RunFirefox(configurationPath, driverOptions); break; case BrowserType.Edge: RunEdge(configurationPath, driverOptions); break; default: throw new WrongParameterException($"Parameter Browser is wrong. It has to be 'Chrome' or 'Firefox' or 'Edge' and it was {browser.ToString()}"); } }
public void ShoppingExperienceInTabletModeTest(BrowserType browserType, int width, int height) { Console.WriteLine($"Browser type - {browserType}, Width - {width}, Height - {height}"); string deviceType = "Tablet"; driver = OpenBrowser(browserType); driver.Url = appURL; driver.Manage().Window.Size = new System.Drawing.Size(width, height); Console.WriteLine(driver.Manage().Window.Size); InduceDelay(3); //Click on the filter menu driver.FindElementByXPath(HomePage.filtersAnchorInTabletMode).Click(); InduceDelay(2); //Click the Black check box in filter panel driver.FindElementByXPath(HomePage.blackColorCheckBoxInTableMode).Click(); InduceDelay(2); //Click on Filter button driver.FindElementByXPath(HomePage.filterButton).Click(); InduceDelay(2); //Validate two products are displayed List <IWebElement> productElements = driver.FindElementsByXPath(PLPage.productListDiv).ToList(); int numberOfProductsDisplayed = productElements.Count; Console.WriteLine($"Number of products displayed - {numberOfProductsDisplayed}"); bool numberOfProductDisplayedResult; if (numberOfProductsDisplayed.Equals(2)) { numberOfProductDisplayedResult = true; } else { numberOfProductDisplayedResult = false; } int taskCount = 1; Utils.HackathonReport($"---------- Validation for Shopping Experience task in TABLET mode starts ---------- ", fileName); Utils.HackathonReport(taskCount, "Shopping Experience Test - Display of two products", PLPage.productListDiv, browserType.ToString(), width, height, deviceType, (numberOfProductDisplayedResult ? "Pass" : "Fail"), fileName); if (numberOfProductDisplayedResult) { ValidateProductListElement(productElements, browserType, width, height, deviceType, taskCount); } Utils.HackathonReport($"---------- Validation for Shopping Experience task in TABLET mode ends ---------- ", fileName); //Since multiple objects are checked in this test, please look into the test report file for the validation details. Assert.IsTrue(true, $"Please check the hackathon report for detailed results"); }
/// <summary> /// set the browser type /// </summary> /// <param name="browserType"> browse type to be assigned </param> public void setBrowserType(BrowserType browserType) { this.browserType = browserType.ToString(); }
/// <summary> /// Creates new browser info object /// </summary> /// <param name="browserType"> </param> /// <param name="browserVersion"></param> public BrowserInfo(BrowserType browserType, string browserVersion) { this.browserType = browserType.ToString(); this.browserVersion = browserVersion; }
/// <summary> /// Retrieves a single browser object from the browsers found on the local machine /// This is extracted as a method for testing purposes. /// </summary> /// <param name="browsers"></param> /// <param name="browserType"></param> /// <returns></returns> internal static Browser GetBrowser(List <Browser> browsers, BrowserType browserType) { return(GetBrowsers().Where(x => x.Name.Replace(" ", "_").ToUpper().Contains(browserType.ToString())).FirstOrDefault()); }
/// <summary> /// Starts the web pages with the default browser with one or more browsers /// </summary> /// <param name="types">The browser types to open</param> /// <param name="address">The the address to be started</param> public static void Open(BrowserType types, string address) { Uri link; if (ValidateAddress(address, out link)) { return; } var values = types.ToString() .Split(new[] { ", ", "| " }, StringSplitOptions.None) .Select(v => (BrowserType)Enum.Parse(typeof(BrowserType), v)); var subKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Clients\\StartMenuInternet\\"); if (subKey == null) { Console.WriteLine("Cannot find any registered browsers"); return; } foreach (var browserType in values) { var keyType = String.Empty; switch (browserType) { case BrowserType.Chrome: keyType = "Google Chrome"; break; case BrowserType.InternetExplorer: keyType = "IEXPLORE.EXE"; break; case BrowserType.Firefox: keyType = "FIREFOX.EXE"; break; case BrowserType.Safari: keyType = "Safari.exe"; break; } if (string.IsNullOrEmpty(keyType)) { continue; } var type = subKey.GetSubKeyNames().Where(name => name == keyType); if (!type.Any()) { Console.WriteLine("Unable to start {0} with {1}, Browser not found", address, browserType); continue; } var command = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(String.Format("SOFTWARE\\Clients\\StartMenuInternet\\{0}\\shell\\open\\command", keyType)); if (command == null) { Console.WriteLine("Unable to find command registry entry for {0}", browserType); continue; } var exe = command.GetValue("") as string; System.Diagnostics.Process.Start(exe, address); } }
public void TestUpdateOpportunity() { using (var xrmBrowser = new XrmBrowser(TestSettings.Options)) { try { Logs.LogHTML(string.Empty, Logs.HTMLSection.Header, Logs.TestStatus.NA, this.GetType().Name, Helper.SecureStringToString(_username), _browser.ToString()); xrmBrowser.LoginPage.Login(_xrmUri, _username, _password); xrmBrowser.GuidedHelp.CloseGuidedHelp(); Logs.LogHTML("Logged in Successfully", Logs.HTMLSection.Details, Logs.TestStatus.Pass); xrmBrowser.ThinkTime(500); xrmBrowser.Navigation.OpenSubArea("Sales", "Opportunities"); Logs.LogHTML("Navigated to Opportunities Successfully", Logs.HTMLSection.Details, Logs.TestStatus.Pass); //xrmBrowser.ThinkTime(200); //xrmBrowser.Grid.SwitchView("Open Opportunities"); xrmBrowser.Grid.Search("PES_Testing_3"); xrmBrowser.ThinkTime(1000); var results = xrmBrowser.Grid.GetGridItems(); if (results.Value != null || results.Value.Count > 0) { xrmBrowser.Grid.OpenRecord(0); Logs.LogHTML("Opportunity Found Successfully.", Logs.HTMLSection.Details, Logs.TestStatus.Fail); } else { Logs.LogHTML("Opportunity not Found.", Logs.HTMLSection.Details, Logs.TestStatus.Fail); } // xrmBrowser.ThinkTime(1000); //xrmBrowser.Navigation.GlobalSearch("PES_Testing_3"); //xrmBrowser.ThinkTime(1000); //xrmBrowser.Grid.OpenRecord(0); //xrmBrowser.Entity.SetValue("identifycompetitors", true); xrmBrowser.ThinkTime(1000); xrmBrowser.BusinessProcessFlow.SelectStage(0); xrmBrowser.ThinkTime(1000); try { xrmBrowser.BusinessProcessFlow.SetActive(); } catch (Exception ex) { //if (ex.Message.ToLower().Contains("click")) } finally { xrmBrowser.BusinessProcessFlow.NextStage(); } //xrmBrowser.Entity. xrmBrowser.Entity.SetValue("header_process_customerneed", "test content"); xrmBrowser.ThinkTime(1000); try { xrmBrowser.Entity.SetValue("header_process_proposedsolution", "test content"); } catch (Exception ex) { } xrmBrowser.ThinkTime(1000); xrmBrowser.Entity.SetValue("header_process_identifycompetitors"); xrmBrowser.Entity.SetValue("header_process_identifycustomercontacts"); //xrmBrowser.BusinessProcessFlow.SelectStage(2); xrmBrowser.BusinessProcessFlow.NextStage(); xrmBrowser.ThinkTime(1000); xrmBrowser.Entity.SetValue("header_process_identifypursuitteam"); xrmBrowser.Entity.SetValue("header_process_developproposal"); xrmBrowser.Entity.SetValue("header_process_completeinternalreview"); xrmBrowser.Entity.SetValue("header_process_presentproposal"); xrmBrowser.BusinessProcessFlow.NextStage(); //xrmBrowser.BusinessProcessFlow.SelectStage(3); xrmBrowser.ThinkTime(1000); xrmBrowser.Entity.SetValue("header_process_completefinalproposal"); xrmBrowser.Entity.SetValue("header_process_presentfinalproposal"); xrmBrowser.Entity.SetValue("header_process_finaldecisiondate", DateTime.Parse("12/2/1984")); xrmBrowser.ThinkTime(1000); xrmBrowser.Entity.SetValue("header_process_sendthankyounote"); xrmBrowser.Entity.SetValue("header_process_filedebrief"); xrmBrowser.BusinessProcessFlow.Finish(); Logs.LogHTML("Updated Opportunity Successfully", Logs.HTMLSection.Details, Logs.TestStatus.Pass); // xrmBrowser.Entity.SetValue("identifycompetitors", "mark complete"); // //xrmBrowser.BusinessProcessFlow. //xrmBrowser.BusinessProcessFlow.SetActive(); // //Field fld = new Field(); //xrmBrowser.Entity.SetValue(fi) //xrmBrowser.BusinessProcessFlow.SelectStage(2); //xrmBrowser.Entity.SetValue("description", "Testing the update api for Opportunity"); // xrmBrowser.Entity.Save(); } catch (Exception ex) { Logs.LogHTML("Update Opportunity Failed : " + ex.Message, Logs.HTMLSection.Details, Logs.TestStatus.Fail); } } }