Exemplo n.º 1
0
		public static void ShouldPresentLicenseList( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "" );

				WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
				wait.Until( d => driver.Title.Equals( "Licenses" ) );
			}
		}
Exemplo n.º 2
0
		public static void ShouldIncludeAtLeastOneLicense( RemoteWebDriver driver, AuthenticatingNavigator navigator ) 
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "license" );
				
				// Even when cold, 5 seconds is a long time to wait
				WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
				wait.Until( d => driver.FindElementsByCssSelector( "#licenses tr" ).Count > 0 );
			}
		}
Exemplo n.º 3
0
		public static void ShouldIncludeAtLeastOneCustomer( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "Sp.Web.Consume/customer" );
				// If we cannot respond in 5 seconds for any reason, a human will seriously distrust the software, no excuses
				WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
				wait.Until( d => d
					.FindElement( By.Id( "customers" ) )
					.FindElements( By.TagName( "tr" ) )
					.Count > 0 );
			}
		}
Exemplo n.º 4
0
		public static void ShouldContainCustomerUsername( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "" );
                WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
                var userSettingsMenu = wait.Until( d => driver.FindElementByCssSelector( "button[name='settings']" ) );
                userSettingsMenu.Click();
                var usernameElement = wait.Until( d => driver.FindElementByCssSelector( "li[id='username']" ) );

				Assert.Contains( ConfigurationManager.AppSettings[ "PortalUsername" ], usernameElement.Text );
			}
		}
Exemplo n.º 5
0
		public static void SignoffShouldRedirectToHostRoot( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "" );
				WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
                var userSettingsMenu = wait.Until( d => driver.FindElementByCssSelector( "button[name='settings']" ) );
                userSettingsMenu.Click();
                var logoffButton = wait.Until( d => driver.FindElementByCssSelector( "a[name='logoff']" ) );

				var portalUrl = new Uri( driver.Url );
				logoffButton.Click();

				var signoffLandingUrl = new Uri( driver.Url );
				Assert.Equal( portalUrl.Authority, signoffLandingUrl.Authority );
			}
		}
Exemplo n.º 6
0
		static void DeletesAndAddsShouldBeEvidentOnRefresh( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "tag" );

				// Once the 'Add New Tag' button becomes enabled, we know that all tags have been loaded
				WebDriverWait shortWait = new WebDriverWait( driver, TimeSpan.FromSeconds( 2 ) );
				shortWait.Until( d => d.FindElement( By.Id( "add_new_tag" ) ).Enabled );
				//TODO TP 1650 - an enabled 'Add New Tag' button doesn't guarantee that the rendering is finished in Chrome; doing some unconditional wait...
				Thread.Sleep( 1000 );

				// Delete all except the first (if there is one)
				foreach ( IWebElement item in driver.FindElements( By.CssSelector( "button.delete" ) ).Skip( 1 ) )
					item.Click();

				shortWait.Until( d => d.FindElements( By.CssSelector( "input.tag_name" ) ).Count <= 1 );

				// Add a fresh one; give it a name
				driver.FindElement( By.Id( "add_new_tag" ) ).Click();
				var newTagInputElement = driver.FindElements( By.CssSelector( "input.tag_name" ) ).Last();
				newTagInputElement.Clear();
				newTagInputElement.Click();
				var newTagName = new Fixture().CreateAnonymous<string>();
				newTagInputElement.SendKeys( newTagName );

				string[] tagsAsSubmitted = SaveAndRecordSubmittedTags( driver );

				// Need a retry in case the initial load loads data which does not include the (eventually consistent) changes
				new WebDriverWaitIgnoringNestedTimeouts( driver, TimeSpan.FromSeconds( 7 ) ).Until( _ =>
				{
					driver.Navigate().Refresh();
					// Verify reloading the page shows the same tags pretty quickly
					return shortWait.Until( d =>
						d.FindElement( By.Id( "add_new_tag" ) ).Enabled
						&& tagsAsSubmitted.SequenceEqual( d.FindElements( By.CssSelector( "input.tag_name" ) ).Select( tagNameEl => tagNameEl.GetAttribute( "value" ).Trim() ) ) );
				} );
			}
		}
Exemplo n.º 7
0
		public static void CreateCustomerShouldSucceed( RemoteWebDriver driver, AuthenticatingNavigator navigator )
		{
			using ( driver.FinallyQuitGuard() ) // TODO improve this using http://xunit.codeplex.com/workitem/9798 ( WAS: http://xunit.codeplex.com/discussions/362097 )
			{
				navigator.NavigateWithAuthenticate( driver, "Sp.Web.Consume/Customer/Create" );

				WebDriverWait wait = new WebDriverWait( driver, TimeSpan.FromSeconds( 5 ) );
				wait.Until( d => d.FindElement( By.Id( "create-view" ) ) );
				IWebElement nameElement = driver.FindElement( By.Id( "name" ) );
				string anonymousCustomerName = "anonymousName" + Guid.NewGuid();
				nameElement.SendKeys( anonymousCustomerName );

				IWebElement externalIdElement = driver.FindElement( By.Id( "externalId" ) );
				externalIdElement.SendKeys( "anonymousExternalId" );

				IWebElement createButton = driver.FindElement( By.Id( "add-customer" ) );
				createButton.Click();

				wait.Until( d => d
					.FindElement( By.Id( "messages" ) )
					.Text.Contains( "Customer created successfully" ) );
			}
		}