本文整理汇总了C#中OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByCssSelector方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteWebDriver.FindElementByCssSelector方法的具体用法?C# RemoteWebDriver.FindElementByCssSelector怎么用?C# RemoteWebDriver.FindElementByCssSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Remote.RemoteWebDriver
的用法示例。
在下文中一共展示了RemoteWebDriver.FindElementByCssSelector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubmitLoginForm
public static void SubmitLoginForm(RemoteWebDriver browser, string email, string password)
{
var formSelector = "form[action^='/Account/Login'] ";
browser.FindElementByCssSelector(formSelector + "input#Email").SendKeys(email);
browser.FindElementByCssSelector(formSelector + "input#Password").SendKeys(password);
browser.FindElementByCssSelector(formSelector + "input[value='Log in']").Click();
WaitUntilUserIsLoggedIn(browser);
}
示例2: SetValueForChosenJQueryControl
public static void SetValueForChosenJQueryControl(RemoteWebDriver browser, string cssSelector, string value)
{
browser.FindElementByCssSelector(cssSelector); // ensure the form field is present
// Click a contained ".chzn-single" element, if available
var clickTarget = browser.FindElementByCssSelector(cssSelector + " .chzn-single");
clickTarget.Click();
browser.FindElementByCssSelector(cssSelector + " input[type=text]").SendKeys(value + Keys.Tab);
}
示例3: ShouldContainCustomerUsername
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 );
}
}
示例4: CreateAccountRightsFor
public static void CreateAccountRightsFor(RemoteWebDriver browser, string userEmail, ObjectTypes objectType, string objectName)
{
browser.FindElementByCssSelector("a[href='/Account']").Click();
var vendorUserRow =
browser.FindElementByLinkText(userEmail).FindElement(By.XPath("./ancestor::tr"));
vendorUserRow.FindElement(By.CssSelector("a[href^='/Account/Edit']")).Click();
browser.FindElementByCssSelector("a[href^='/AccountRights/Create'][href$='" + Enum.GetName(typeof(ObjectTypes), objectType) + "']").Click();
SiteUtil.SetValueForChosenJQueryControl(browser, "#ObjectId_chzn", objectName);
browser.FindElementByCssSelector("form[action^='/AccountRights/Create'] input[type='submit']").Click();
browser.FindElementByCssSelector(".success");
}
示例5: SignoffShouldRedirectToHostRoot
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 );
}
}
示例6: CreateVendor
public static string CreateVendor(RemoteWebDriver browser)
{
string vendorName = "vendor name";
browser.FindElementByCssSelector("a[href='/Vendor']").Click();
browser.FindElementByCssSelector("a[href='/Vendor/Create']").Click();
browser.FindElementByCssSelector("input#Vendor_Name").SendKeys(vendorName);
browser.FindElementByCssSelector("input#Vendor_Street").SendKeys("vendor street");
browser.FindElementByCssSelector("input#Vendor_PostalCode").SendKeys("vendor street");
browser.FindElementByCssSelector("input#Vendor_City").SendKeys("vendor city");
browser.FindElementByCssSelector("input#Vendor_Region").SendKeys("vendor region");
browser.FindElementByCssSelector("form[action='/Vendor/Create'] input[type=submit]").Click();
browser.FindElementByCssSelector(".success");
return vendorName;
}
示例7: SetValueForChosenJQueryControlMulti
public static void SetValueForChosenJQueryControlMulti(
RemoteWebDriver browser,
string cssSelector, string value,
bool clearExisting = false)
{
var clickTarget = browser.FindElementByCssSelector(cssSelector);
clickTarget.Click();
if (clearExisting)
{
foreach (var removeButton in browser.FindElementsByCssSelector(cssSelector + " li .search-choice-close"))
{
removeButton.Click();
}
}
var selection =
browser.FindElementsByCssSelector(cssSelector + " li").FirstOrDefault(e => e.Text.Contains(value));
Assert.NotNull(selection);
selection.Click();
}
示例8: FillVendorCredentialForm
private static void FillVendorCredentialForm(RemoteWebDriver browser, string name, string value)
{
browser.FindElementByCssSelector("input#CredentialName").Clear();
browser.FindElementByCssSelector("input#CredentialName").SendKeys(name);
browser.FindElementByCssSelector("input#CredentialValue").Clear();
browser.FindElementByCssSelector("input#CredentialValue").SendKeys(value);
}
示例9: SubmitTransactionCheckoutFormWithNewCustomer
private static void SubmitTransactionCheckoutFormWithNewCustomer(RemoteWebDriver browser)
{
var formSelector = "form[action^='/Transaction/Checkout'] ";
browser.FindElementByCssSelector(formSelector + "input#NewPurchasingCustomer_Customer_Name")
.SendKeys("customerName");
browser.FindElementByCssSelector(formSelector + "input#NewPurchasingCustomer_Customer_Street")
.SendKeys("123 Fake St.");
browser.FindElementByCssSelector(formSelector + "input#NewPurchasingCustomer_Customer_PostalCode").SendKeys("98105");
browser.FindElementByCssSelector(formSelector + "input#NewPurchasingCustomer_Customer_City").SendKeys("Seattle");
browser.FindElementByCssSelector(formSelector + "input#NewPurchasingCustomer_Customer_Region").SendKeys("WA");
browser.FindElementByCssSelector(formSelector + "input[type=submit]").Click();
}
示例10: AssertVendorCredentialFormValues
private static void AssertVendorCredentialFormValues(RemoteWebDriver browser, string name, string value)
{
Assert.Equal(name, browser.FindElementByCssSelector("input#CredentialName").GetAttribute("value"));
Assert.Equal(value, browser.FindElementByCssSelector("input#CredentialValue").GetAttribute("value"));
}
示例11: FindElement
protected IWebElement FindElement(RemoteWebDriver webDriver, Selector element)
{
switch (element.Type)
{
case ExtractType.XPath:
{
return webDriver.FindElementByXPath(element.Expression);
}
case ExtractType.Css:
{
return webDriver.FindElementByCssSelector(element.Expression);
}
}
throw new SpiderExceptoin("Unsport findy: " + element.Type);
}
示例12: GetAppKeyFromTransactionCompletePage
private static Guid GetAppKeyFromTransactionCompletePage(RemoteWebDriver browser)
{
var appKeyValue = Guid.Parse(browser.FindElementByCssSelector("#customerAppKeyValue").Text.Trim());
return appKeyValue;
}
示例13: SubmitRegistrationForm
public static void SubmitRegistrationForm(RemoteWebDriver browser, string email, string password)
{
browser.FindElementByCssSelector("input[name=Email]").SendKeys(email);
browser.FindElementByCssSelector("input[name=Password]").SendKeys(password);
browser.FindElementByCssSelector("input[name=ConfirmPassword]").SendKeys(password);
browser.FindElementByCssSelector("input[value=Register]").Click();
}
示例14: AssertApplicationNameIs
private void AssertApplicationNameIs(RemoteWebDriver browser, string expectedName)
{
var applicationLink = browser.FindElementByCssSelector("a[href^='/CustomerApp/Details']");
Assert.Equal(expectedName, applicationLink.Text.Trim());
}
示例15: GetCurrentUserId
int GetCurrentUserId(RemoteWebDriver browser)
{
browser.FindElementByCssSelector("a[href='/Account']").Click();
var editLink = browser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href");
return int.Parse(Regex.Match(editLink, @"(\d+)$").Groups[1].Value);
}