public void SelectableV1() { driver = NavigateHelper.NavigateDemoqa(); wait = common.Wait(driver); SelectableV1ObjectHelper selectableV1ObjectHelper = new SelectableV1ObjectHelper(); SelectableV1AssertValues selectableV1AssertValues = new SelectableV1AssertValues(); IWebElement interactions = wait.Until(drv => drv.FindElement(By.CssSelector(selectableV1ObjectHelper.interactionsOptionSelector))); interactions.Click(); driver.ExecuteScript("window.scroll(0,250)"); IWebElement selectable = wait.Until(drv => drv.FindElement(By.CssSelector(selectableV1ObjectHelper.selectable))); selectable.Click(); //IWebElement firstItem = wait.Until(drv => drv.FindElement(By.CssSelector("#verticalListContainer>li:nth-child(1)"))); //firstItem.Click(); IWebElement secondItem = wait.Until(drv => drv.FindElement(By.CssSelector(selectableV1ObjectHelper.secondItem))); Actions actions = new Actions(driver); actions.MoveToElement(secondItem).Build().Perform(); secondItem.Click(); //Assert.AreEqual(secondItem.GetAttribute("class"), "mt-2 list-group-item active list-group-item-action"); string Color = secondItem.GetCssValue(selectableV1AssertValues.backgroundColor); Assert.AreEqual(Color, selectableV1AssertValues.selectedColorCode); }
public void TestsSetUp() { driver = new ChromeDriver(); NavigateHelper navigator = new NavigateHelper(driver); driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30); loginPage = navigator.GoToLoginPage(); }
public static void GoTo <TViewModel>(this NavigateHelper <TViewModel> uriBuilder) { var navigationService = IoC.Get <INavigationService>(); uriBuilder.Navigate(); while (navigationService.BackStack.Count > 0) { navigationService.BackStack.RemoveAt(0); } }
void Generate() { try { BusyIndicator.Show(); NavigateItems = NavigateHelper.Scan(Roots); GenerateTreeSource(); } finally { BusyIndicator.Close(); } }
public void SelectAnItem() { NavigateHelper.NavigateDemoqa("chrome"); SelectionObjectHelper selectionObjectHelper = new SelectionObjectHelper(); SelectionAssertValues selectionAssertValues = new SelectionAssertValues(); IWebElement selectable = wait.Until(drv => drv.FindElement(By.CssSelector(selectionObjectHelper.selectableLink))); selectable.Click(); wait = new WebDriverWait(driver, TimeSpan.FromSeconds(25)); IWebElement itemSelect = wait.Until(drv => drv.FindElement(By.CssSelector(selectionObjectHelper.firstItem))); itemSelect.Click(); Assert.AreEqual(itemSelect.GetAttribute("class"), selectionAssertValues.selectedItemClass); }
public void Draggable() { NavigateHelper.NavigateDemoqa(); DragObjectHelper dragObjectHelper = new DragObjectHelper(); IWebElement draggable = wait.Until(drv => drv.FindElement(By.CssSelector(dragObjectHelper.draggableLink))); draggable.Click(); IWebElement dragElement = wait.Until(drv => drv.FindElement(By.CssSelector(dragObjectHelper.dragItem))); var oldX = dragElement.Location.X; Actions actions = new Actions(driver); actions.DragAndDropToOffset(dragElement, 100, 100).Build().Perform(); Assert.AreNotEqual(oldX, dragElement.Location.X); }
public void Resizable() { NavigateHelper.NavigateDemoqa(); ResizeObjectHelper resizeObjectLayer = new ResizeObjectHelper(); IWebElement resizable = wait.Until(drv => drv.FindElement(By.CssSelector(resizeObjectLayer.resizableLink))); resizable.Click(); IWebElement dragElement = wait.Until(drv => drv.FindElement(By.CssSelector(resizeObjectLayer.dragElement))); Actions actions = new Actions(driver); IWebElement resizableElement = wait.Until(drv => drv.FindElement(By.CssSelector(resizeObjectLayer.resizableElement))); var resizableElementHeight = resizableElement.Size.Height; actions.DragAndDropToOffset(dragElement, 100, 100).Build().Perform(); Assert.AreNotEqual(resizableElementHeight, resizableElement.Size.Height); }
public void DragAndDrop() { NavigateHelper.NavigateDemoqa(); DragAndDropAssertValues dragAndDropAssertValues = new DragAndDropAssertValues(); DragAndDropObjectHelper dragAndDropObjectHelper = new DragAndDropObjectHelper(); IWebElement dragAndDrop = wait.Until(drv => drv.FindElement(By.CssSelector(dragAndDropObjectHelper.dragAndDropLink))); dragAndDrop.Click(); IWebElement dragElement = wait.Until(drv => drv.FindElement(By.CssSelector(dragAndDropObjectHelper.dragItem))); IWebElement dropElement = wait.Until(drv => drv.FindElement(By.CssSelector(dragAndDropObjectHelper.dropItem))); Actions actions = new Actions(driver); actions.DragAndDrop(dragElement, dropElement).Build().Perform(); IWebElement droppedTextElement = wait.Until(drv => drv.FindElement(By.CssSelector(dragAndDropAssertValues.droppedTextElement))); Assert.AreEqual(droppedTextElement.Text, dragAndDropAssertValues.dropText); }
public static void Navigate <TViewModel>(this NavigateHelper <TViewModel> uriBuilder, INavigationService navigationService, Action <TViewModel> action) where TViewModel : class { NavigatedEventHandler navigationServerOnNavigated = null; navigationServerOnNavigated = (s, e) => { var viewModel = ViewModelLocator.LocateForView(e.Content) as TViewModel; if (viewModel != null) { action(viewModel); } navigationService.Navigated -= navigationServerOnNavigated; }; navigationService.Navigated += navigationServerOnNavigated; uriBuilder.Navigate(); }
/// <summary> /// 重定向页面 /// </summary> public static void Redirect <TViewModel>(this NavigateHelper <TViewModel> navigateHelper, bool animated = true) { //获取导航页 NavigationPage navigationPage = ResolveMediator.Resolve <NavigationPage>(); //获取导航前页面 IList <Page> prevPages = new List <Page>(navigationPage.Navigation.NavigationStack); //导航至新页面 navigateHelper.Navigate(animated); //移除导航前页面 foreach (Page prevPage in prevPages) { navigationPage.Navigation.RemovePage(prevPage); } }
public void SelectItems() { NavigateHelper.NavigateDemoqa(); SelectionObjectHelper selectionObjectHelper = new SelectionObjectHelper(); SelectionAssertValues selectionAssertValues = new SelectionAssertValues(); IWebElement selectable = wait.Until(drv => drv.FindElement(By.CssSelector(selectionObjectHelper.selectableLink))); selectable.Click(); Actions action = new Actions(driver); action.KeyDown(Keys.Control).Build().Perform(); IWebElement firstItem = wait.Until(drv => drv.FindElement(By.CssSelector(selectionObjectHelper.firstItem))); firstItem.Click(); IWebElement secondItem = wait.Until(drv => drv.FindElement(By.CssSelector(selectionObjectHelper.secondItem))); secondItem.Click(); action.KeyUp(Keys.Control).Build().Perform(); Assert.AreEqual(firstItem.GetAttribute("class"), selectionAssertValues.expectedValueDictionary["firstItem"]); Assert.AreEqual(secondItem.GetAttribute("class"), selectionAssertValues.expectedValueDictionary["secondItem"]); }
// [AssemblyInitialize] public static void Initialize(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext tc) { switch (ConfigurationManager.AppSettings.Get(AppConfigKeys.Browser)) { case "Firefox": ObjectRepository.Driver = GetFirefoxDriver(); NavigateHelper.WebSite(ConfigurationManager.AppSettings.Get(AppConfigKeys.WebSite)); break; case "Chrome": ObjectRepository.Driver = GetChromeBrowseer(); NavigateHelper.WebSite(ConfigurationManager.AppSettings.Get(AppConfigKeys.WebSite)); break; case "IE": // ObjectRepository.IEOptions = GetIEDriver(); ObjectRepository.Driver = new InternetExplorerDriver(GetIEDriver()); NavigateHelper.WebSite(ConfigurationManager.AppSettings.Get(AppConfigKeys.WebSite)); break; } }
public void GivenUserIsAtLoginPageWithTitle(string title) { NavigateHelper.WebSite(ConfigurationManager.AppSettings.Get(AppConfigKeys.WebSite)); Assert.AreEqual(title, ObjectRepository.Driver.Title); }
public void PositiveTestsSetUp() { driver = new ChromeDriver(); navigator = new NavigateHelper(driver); loginPage = navigator.GoToLoginPage(); }