本文整理汇总了C#中IWebDriver.IsElementPresent方法的典型用法代码示例。如果您正苦于以下问题:C# IWebDriver.IsElementPresent方法的具体用法?C# IWebDriver.IsElementPresent怎么用?C# IWebDriver.IsElementPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebDriver
的用法示例。
在下文中一共展示了IWebDriver.IsElementPresent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
protected override bool Run(IWebDriver driver)
{
var testSuccessful = false;
Log("testSuccessful: " + testSuccessful.ToString());
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(30));
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30));
try
{
driver.Navigate().GoToUrl(baseURL + "/index.html");
driver.FindElement(By.CssSelector("dd.foto > a > img")).Click();
driver.FindElement(By.LinkText("comprar")).Click();
//Se for um produto que tenha serviço, não seleciona nenhum [serviço] e vai embora
if (driver.Url.IndexOf("DetalheServico.aspx") > -1)
{
Log("É página de serviço");
Log("Checkbox ckbLiConcordoGarantia:" + driver.IsElementPresent(By.Id("ckbLiConcordoGarantia")).ToString());
driver.FindElement(By.Id("ckbLiConcordoGarantia")).Click();
Log("Checkbox ckbLiConcordoGarantia:" + driver.IsElementPresent(By.ClassName("btAvancar")).ToString());
driver.FindElement(By.ClassName("btAvancar")).Click();
}
driver.FindElement(By.CssSelector("img.bt_limpar")).Click();
driver.FindElement(By.Id("txtEmail")).Clear();
driver.FindElement(By.Id("txtEmail")).SendKeys("[email protected]");
driver.FindElement(By.Id("txtSenha")).Clear();
driver.FindElement(By.Id("txtSenha")).SendKeys("321321");
driver.FindElement(By.CssSelector("a.btOk.enviaForm > span")).Click();
driver.FindElement(By.Id("182638")).Click();
driver.FindElement(By.XPath("//a[contains(@rel,'boletoItau')]")).Click();
driver.FindElement(By.CssSelector("input.txtcpfcnpjboleto")).Clear();
driver.FindElement(By.CssSelector("input.txtcpfcnpjboleto")).SendKeys("34238009843");
driver.FindElement(By.CssSelector("img[alt=\"Clique aqui para Finalizar a compra\"]")).Click();
testSuccessful = driver.IsElementPresent(By.Id("nrPedido"));
driver.FindElement(By.CssSelector("#btVoltar > img")).Click();
driver.FindElement(By.LinkText("sair")).Click();
Log("testSuccessful: " + testSuccessful.ToString());
return testSuccessful;
}
catch (Exception ex)
{
Log("Exception -> " + ex.Message);
return false;
}
}