public void SeleniumGenerator_TestNormalizeUniqueName() { // initialize var testString = "My superb String"; // do var resultString = SelectorStringHelper.RemoveNonIdentifierCharacters(testString); // assert var expectedString = "MySuperbString"; Assert.AreEqual(resultString, expectedString); }
public void SeleniumGenerator_TestRemovingNonIdentifierCharacters() { // initialize var testString = "__Ahoj1234@\'PTest Test"; // do var resultString = SelectorStringHelper.RemoveNonIdentifierCharacters(testString); // assert var expectedString = "__Ahoj1234PTestTest"; Assert.AreEqual(resultString, expectedString); }
/// <summary> /// Gets a list of declarations emitted by the control. /// </summary> public void AddDeclarations(PageObjectDefinition pageObject, SeleniumGeneratorContext context) { string propertyName; var htmlName = SelectorStringHelper.TryGetNameFromProperty(context.Control, UITests.NameProperty); if (htmlName == null) { // determine the name propertyName = DetermineName(pageObject, context); } else { propertyName = htmlName; } // normalize name var normalizedName = SelectorStringHelper.RemoveNonIdentifierCharacters(propertyName); // make the name unique var uniqueName = MakePropertyNameUnique(context.UsedNames, normalizedName); context.UsedNames.Add(uniqueName); context.UniqueName = uniqueName; // determine the selector if (htmlName == null) { context.Selector = uniqueName; AddUITestNameProperty(pageObject, context, uniqueName); } else { context.Selector = htmlName; } context.UsedNames.Add(propertyName); AddDeclarationsCore(pageObject, context); }