本文整理汇总了C#中WebDriverWait类的典型用法代码示例。如果您正苦于以下问题:C# WebDriverWait类的具体用法?C# WebDriverWait怎么用?C# WebDriverWait使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebDriverWait类属于命名空间,在下文中一共展示了WebDriverWait类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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();
}
}
示例4: 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);
}
示例5: 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());
}
示例6: 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")));
}
示例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);
}
}
示例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");
}
}
示例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")));
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
});
}
示例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();
}
示例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();
}
}