本文整理汇总了C#中WebDriverWait类的典型用法代码示例。如果您正苦于以下问题:C# WebDriverWait类的具体用法?C# WebDriverWait怎么用?C# WebDriverWait使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebDriverWait类属于命名空间,在下文中一共展示了WebDriverWait类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Wait
public static void Wait(int miliseconds, int maxTimeOutSeconds = 60)
{
var wait = new WebDriverWait(Driver, new TimeSpan(0, 0, 1, maxTimeOutSeconds));
var delay = new TimeSpan(0, 0, 0, 0, miliseconds);
var timestamp = DateTime.Now;
wait.Until(webDriver => (DateTime.Now - timestamp) > delay);
}
开发者ID:AlexMoll91,项目名称:SeleniumExample,代码行数:7,代码来源:SeleniumHelper.cs
示例2: GetPageFilterList
public string GetPageFilterList()
{
driver.SwitchTo().Frame(investigationFRAME);
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
IWebElement element = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#crmGrid_rta_systemuser_rta_inv_case_investigatorid_SavedNewQuerySelector>span")));
return element.Text;
}
开发者ID:pjagga,项目名称:SeleniumMSTestVS2013,代码行数:7,代码来源:UserPage.cs
示例3: ShouldMoveAvatar
public void ShouldMoveAvatar()
{
IWebDriver driver = Tools.CreateDriver();
try
{
driver.Navigate().GoToUrl(
"http://localhost/projects/test-client/client.xhtml#FIVESTesting&OverrideServerPort=34837");
Tools.Login(driver, "1", "");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IJavaScriptExecutor jsExecutor = driver as IJavaScriptExecutor;
// Wait for the FIVES.AvatarEntityGuid to become available.
string avatarGuid = (string)wait.Until(d => jsExecutor.ExecuteScript("return FIVES.AvatarEntityGuid"));
// Wait until avatar's transform element becomes available.
IWebElement avatarTransform = wait.Until(d => d.FindElement(By.Id("transform-" + avatarGuid)));
string startTranslation = avatarTransform.GetAttribute("translation");
jsExecutor.ExecuteScript("$(document).trigger({type: 'keydown', which: 87, keyCode: 87})");
// Wait until avatar starts to move.
wait.Until(d => avatarTransform.GetAttribute("translation") != startTranslation);
}
finally
{
driver.Quit();
}
}
开发者ID:FaisalZ,项目名称:FiVES,代码行数:30,代码来源:AvatarTests.cs
示例4: NavigateToDraftFolder
public static void NavigateToDraftFolder()
{
Console.WriteLine("Navigating to Draft folder...");
driver.FindElement(By.XPath("//*[@id='b-nav_folders']/div/div[3]/a/span")).Click();
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(d => d.FindElement(By.Id("b-letters")));
}
开发者ID:AlexNaryzhny,项目名称:helloci,代码行数:7,代码来源:TestMailRu.cs
示例5: LoginProfile
public static void LoginProfile()
{
BaseTest.BaseUrl = GooglePage.HomePageUrl;
BaseTest.Setup(BaseTest.BaseUrl);
WebDriverWait wait = new WebDriverWait(BaseTest.BaseDriver, TimeSpan.FromSeconds(5));
wait.Until((d) => { return d.Title.StartsWith("Google"); });
GooglePage.AreAllElementShown();
// login btn
GooglePage.LoginBtn.Click();
// login page
// Sign in - Google Accounts
Thread.Sleep(1500);
Assert.AreEqual("Вход – Google Профили", BaseTest.BaseDriver.Title);
Assert.IsTrue(GooglePage.EmailInput.Displayed);
GooglePage.EmailInput.Clear();
GooglePage.EmailInput.SendKeys("testqaexam");
Assert.IsTrue(GooglePage.PasswordInput.Displayed);
GooglePage.PasswordInput.Clear();
GooglePage.PasswordInput.SendKeys("TestPass");
Assert.IsTrue(GooglePage.SigninBtn.Displayed);
GooglePage.SigninBtn.Click();
Thread.Sleep(1500);
}
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:27,代码来源:GoogleLoginTest.cs
示例6: RunTest
public static void RunTest([NotNull] string url,
[NotNull] string initialPageTitle,
[CanBeNull] IEnumerable<Action<IWebDriver>> testSteps)
{
Console.WriteLine(url);
var steps = new List<Action<IWebDriver>>
{
b => b.Navigate().GoToUrl(url),
b =>
{
if (!String.IsNullOrEmpty(initialPageTitle))
{
var wait = new WebDriverWait(b, TimeSpan.FromSeconds(30));
wait.Until(x => b.Title.Equals(initialPageTitle));
b.Title.ShouldBeEqualTo(initialPageTitle, "incorrect page title");
}
}
};
if (testSteps != null)
{
steps.AddRange(testSteps);
}
var notification = _runner.PassesTest(steps) ?? new Notification();
notification.Success.ShouldBeTrue(notification.ToString());
}
开发者ID:mvbalaw,项目名称:FluentWebUITesting,代码行数:28,代码来源:UITestRunner.cs
示例7: TestSportsRu
public void TestSportsRu()
{
Console.WriteLine("Test started!");
const string mailUrl = "https://10minutemail.net";
const string sportsUrl = "https://sports.ru/";
using (D)
{
D.Navigate().GoToUrl(mailUrl);
var wait = new WebDriverWait(D, TimeSpan.FromSeconds(30));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("fe_text")));
D.FindElement(By.Id("fe_text")).Click();
var email = D.FindElement(By.Id("fe_text")).GetAttribute("value");
var username = email.Split('@').First();
var password = "www12342";
D.RegSportsRu(sportsUrl, email, password, username);
D.Navigate().GoToUrl(mailUrl);
Thread.Sleep(5000);
}
}
开发者ID:elv1s42,项目名称:Sandbox,代码行数:25,代码来源:TestSite.cs
示例8: ScrollElement
public ScrollElement(ScrollerItems item)
{
ImageDropName = itemsdrop[item];
ImageDragName = itemsdrag[item];
locator = itempath[item];
var wait = new WebDriverWait(Browser.GetDriver(), TimeSpan.FromMilliseconds(Convert.ToDouble(Configuration.GetTimeout())));
try
{
wait.Until(waiting =>
{
try
{
return Browser.GetDriver().FindElement(locator).GetAttribute("style").Contains("background-image: url");
}
catch (Exception)
{
return false;
}
});
}
catch (WebDriverTimeoutException)
{
Assert.Fail("Cannot wait until image displayed");
}
}
开发者ID:MixolydianBY,项目名称:AutomationDemo,代码行数:25,代码来源:ScrollElement.cs
示例9: WebBlock
public WebBlock(Session session) : base(session)
{
// Wait for the DOM to start changing so we can START waiting for the new element
this.Pause(200);
Wait = new WebDriverWait(Session.Driver, new TimeSpan(3000));
Tag = Wait.Until(driver => driver.GetElement(By.TagName("body")));
}
开发者ID:Bumblebee,项目名称:Bumblebee.Examples,代码行数:7,代码来源:WebBlock.cs
示例10: WaitUntilElementsPresent
public static IEnumerable<IWebElement> WaitUntilElementsPresent(this IWebDriver driver, By selector)
{
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(ExpectedConditions.ElementExists(selector));
return driver.FindElements(selector);
}
开发者ID:mikeedwards83,项目名称:Habitat,代码行数:7,代码来源:SeleniumExtensions.cs
示例11: ClickAddNewTenancyRequestButton
public void ClickAddNewTenancyRequestButton()
{
RefreshPageFrame.RefreshPage(driver, frameId);
this.driver.SwitchTo().Frame(FRAMETenancyRequest);
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(waitsec));
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[alt='Add New Tenancy Request']"))).Click();
}
开发者ID:pjagga,项目名称:SeleniumMSTestVS2013,代码行数:7,代码来源:AddressDetailPage.cs
示例12: sumi
public void sumi()
{
IWebElement element;
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
// webpegeを表示
driver.Navigate().GoToUrl("https://www.f-aspit.com/aspit/portal/login.asp");
driver.FindElement(By.Name("KigyoCD")).SendKeys("99990005");
driver.FindElement(By.Name("UserID")).SendKeys("goen9995");
driver.FindElement(By.Name("Password")).SendKeys("354959");
driver.FindElement(By.CssSelector("img[id='img01']")).Click();
driver.SwitchTo().Frame("fraNews");
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("btnMenu0")));
element = driver.FindElement(By.Name("btnMenu0"));
element.SendKeys(Keys.Enter);
wait.Until(ExpectedConditions.InvisibilityOfElementLocated(By.Name("btnMenu0")));
wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt("main"));
element = driver.FindElement(By.LinkText("受注照会"));
element.SendKeys(Keys.Enter);
driver.FindElement(By.Name("selFromDay")).Click();
driver.FindElement(By.XPath("//span[@id='idTargetKikanArea_From_Day']/select//option[1]")).Click();
driver.FindElement(By.Id("imgDownload")).Click();
//ここにダウンロード処理を入れる
driver.Quit();
}
开发者ID:shigusa,项目名称:Senri,代码行数:27,代码来源:aspit_joune_sumi.cs
示例13: WaitForPageToLoad
public static void WaitForPageToLoad(this IWebDriver driver)
{
TimeSpan timeout = new TimeSpan(0, 0, 100);
WebDriverWait wait = new WebDriverWait(driver, timeout);
IJavaScriptExecutor javaScript = driver as IJavaScriptExecutor;
if (javaScript == null)
throw new ArgumentException("driver", "driver must support javascript execution");
wait.Until((d) =>
{
try
{
string readyState =
javaScript.ExecuteScript("if (document.readyState) return document.readystate;").ToString();
return readyState.ToLower() == "complete";
}
catch (InvalidOperationException e)
{
//Window is no lonfer available
return e.Message.ToLower().Contains("unable to get browser");
}
catch (WebDriverException e)
{
//Browser is no longer available
return e.Message.ToLower().Contains("unable to connect");
}
catch (Exception)
{
return false;
}
});
}
开发者ID:venkatakumar9,项目名称:AKEcommerceAutomationTesting,代码行数:32,代码来源:WaitFor.cs
示例14: SearchNotExistingBug
public void SearchNotExistingBug()
{
BaseTest.BaseUrl = BugTrackerPage.HomePageUrl;
BaseTest.Setup(BaseTest.BaseUrl);
WebDriverWait wait = new WebDriverWait(BaseTest.BaseDriver, TimeSpan.FromSeconds(5));
wait.Until((d) => { return d.Title.StartsWith("BugTracker"); });
BugTrackerPage.AreAllElementShown();
BugTrackerPage.BugIdTextInput.Clear();
BugTrackerPage.BugIdTextInput.SendKeys("123abc");
BugTrackerPage.GotoIdBtn.Click();
try
{
Assert.IsTrue(BugTrackerPage.ErrorMsgLabel.Displayed);
}
catch (NoSuchElementException nsee)
{
Thread.Sleep(1500);
Assert.IsTrue(BugTrackerPage.ErrorMsgLabel.Displayed);
}
string expectedErrMsg = "Error: Bug ID must be an integer.";
Assert.AreEqual(expectedErrMsg, BugTrackerPage.ErrorMsgLabel.Text);
BaseTest.TearDown();
}
开发者ID:ekostadinov,项目名称:MyProjects,代码行数:29,代码来源:SearchNotExistingBugId.cs
示例15: TestExplicitWait
public void TestExplicitWait()
{
IWebDriver driver = new ChromeDriver(@"C:\ChromeDriver");
driver.Navigate().GoToUrl("http://dl.dropbox.com/u/55228056/AjaxDemo.html");
try
{
IWebElement page4button = driver.FindElement(By.LinkText("Page 4"));
page4button.Click();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement message = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.Id("page4"));
});
Assert.IsTrue(message.Text.Contains("Nunc nibh tortor"));
}
catch (NoSuchElementException e)
{
Assert.Fail("Element not found!!");
} finally {
driver.Close();
}
}
开发者ID:oluk68,项目名称:SELENIUM2,代码行数:26,代码来源:ExplicitWaitTests.cs
示例16: QuickSearch
public void QuickSearch(QuickSearchType recordtype, string name)
{
var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15));
var qucikSearchArrow =
wait.Until(
ExpectedConditions.ElementIsVisible(
By.XPath(".//span[contains(text(), 'Search For')]/following::td[2]/a")));
qucikSearchArrow.Click();
const string xPath = "//li[.='{0}']";
var key = string.Format(xPath, recordtype);
wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15));
var module = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(key)));
module.Click();
const string id = "ctl00_{0}_Input";
var record = string.Format(id, QuickSearchInputBoxLibrary[recordtype]);
wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15));
var recordnameinputbx = wait.Until(ExpectedConditions.ElementIsVisible(By.Id(record)));
recordnameinputbx.Click();
recordnameinputbx.SendKeys(name);
const string recordXpath = "//td/span[contains(text(), '{0}')]";
var recordname = string.Format(recordXpath, name);
wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15));
var selectindividual = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(recordname)));
selectindividual.Click();
}
开发者ID:kishonhamilton,项目名称:MemberSuite-Automation,代码行数:35,代码来源:BaselineQuickSearchPage.cs
示例17: GetElementFromActivePage
// This should be replaced for any given application; this isn't a one-size-fits-all sort of thing.
public static IWebElement GetElementFromActivePage(this IWebDriver driver, string cssSelector, double timeoutSeconds = 20)
{
IWebElement element = null;
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutSeconds));
wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(WebDriverTimeoutException),typeof(UnhandledAlertException));
try
{
element = wait.Until(drv =>
{
try
{
return drv.FindElement(By.CssSelector(cssPrefix + cssSelector));
}
catch (NoSuchElementException ex)
{
return null;
}
});
}
catch (WebDriverTimeoutException ex)
{
return null;
}
return element;
}
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:27,代码来源:WebDriverExtensions.cs
示例18: GoToWriteNewPostScreen
public ContentPage GoToWriteNewPostScreen()
{
var wait = new WebDriverWait(Browser.Current, TimeSpan.FromSeconds(10));
var el = wait.Until(drv => drv.FindElement(By.ClassName("btn-header")));
el.Click();
return this;
}
开发者ID:k0stya,项目名称:SpecFlow-Selenium-examples,代码行数:7,代码来源:ContentPage.cs
示例19: Lookup
/// <summary>
/// Lookup a reference field value.
/// </summary>
/// <param name="driver"></param>
/// <param name="by">A mechanism by which to find the desired reference field within the current document.</param>
/// <param name="sendKeys">A property value of the current reference field.</param>
public static void Lookup(this IWebDriver driver, By by, string sendKeys)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
IWebElement lookup = wait.Until(ExpectedConditions.ElementIsVisible(by));
lookup.Click();
string currentWindowHandle = driver.CurrentWindowHandle;
string searchWindow = driver.WindowHandles.First(o => o != currentWindowHandle);
driver.SwitchTo().Window(searchWindow);
IWebElement searchFor = wait.Until(ExpectedConditions.ElementExists(By.ClassName("list_search_text")));
searchFor.Click();
searchFor.Clear();
searchFor.SendKeys(sendKeys);
var selects = driver.FindElements(By.ClassName("list_search_select"));
IWebElement search = selects.First(o => o.GetAttribute("id").Contains("_select"));
driver.SelectOption(search, "Name"); //"for text");
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("img[title='Go']"))).Click();
IWebElement item = wait.Until(ExpectedConditions.ElementExists(By.LinkText(sendKeys)));
item.Click();
driver.SwitchTo().Window(currentWindowHandle);
driver.SwitchTo().Frame("gsft_main");
}
开发者ID:rburkitt,项目名称:ServiceNowWebDriverExtensions,代码行数:35,代码来源:WebDriverExtensions.cs
示例20: PostBody
public ContentPage PostBody(string body)
{
var wait = new WebDriverWait(Browser.Current, TimeSpan.FromSeconds(10));
var el = wait.Until(drv => drv.FindElement(By.Id("editor")));
el.SendKeys(body);
return this;
}
开发者ID:k0stya,项目名称:SpecFlow-Selenium-examples,代码行数:7,代码来源:ContentPage.cs
注:本文中的WebDriverWait类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论