自動テストツール Selenium2 4/5
目次
wait処ç†
wait.Until
//指定ã®ã‚¿ã‚¤ãƒˆãƒ«ã«ãªã‚‹ã¾ã§10ç§’å¾…ã¤ã€‚
//ãªã‚‰ãªã‹ã£ãŸã‚‰NUnitã§ã‚¨ãƒ©ãƒ¼è¡¨ç¤º
WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, 10));
wait.Until(ExpectedConditions.TitleIs(“TEST”));
//指定ã®è¦ç´ ãŒã‚ã‚‹ã‹ãƒã‚§ãƒƒã‚¯
wait.Until(ExpectedConditions.ElementExists(By.Id(“myText”)));
//指定ã®è¦ç´ ãŒå¯è¦–ã‹ãƒã‚§ãƒƒã‚¯
wait.Until(ExpectedConditions.ElementIsVisible(By.Id(“myText”)));
メソッド
Clear()
//è¦ç´ ã®ã‚¯ãƒªã‚¢
IWebElement element = driver.FindElement(By.Id(“myText”));
element.Clear();
//ã“ã†ã„ã†æ›¸ã方もå¯(メソッドãƒã‚§ãƒ¼ãƒ³)
driver.FindElement(By.Name(“myText”)).Clear();
SendKeys()
//è¦ç´ ã¸ã®å…¥åŠ›(追記)
element.SendKeys(“yahoo”);
//ã“ã†ã„ã†æ›¸ã方もå¯(メソッドãƒã‚§ãƒ¼ãƒ³)
driver.FindElement(By.Name(“myText”)).SendKeys(“yahoo”);
Submit()
element.Submit();
Click()
//ボタン・リンクã®ã‚¯ãƒªãƒƒã‚¯
driver.FindElement(By.Name(“btnK”)).Click();
driver.FindElement(By.LinkText(“Selenium – Web Browser Automation”)).Click();
GetAttribute()
//指定è¦ç´ ã®value属性値å–å¾—
Assert.AreEqual(“aaayahoo”, element.GetAttribute(“value”));
GetCssValue()
GetScreenshot()
//スクリーンショットをä¿å˜(bin内)
Screenshot shot = ((ITakesScreenshot)driver).GetScreenshot();
byte[] screenshotAsByteArray = shot.AsByteArray;
shot.SaveAsFile(“firefox.png”, ImageFormat.Png);
プãƒãƒ‘ティ
Displayed
Enabled
Location
Selected
CheckBoxã€Selectç‰
Size
TagName
Text
タグ間テã‚スト