qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請訪問 http://qaseven.github.io/

          Selenium WebDriver如何查找WebElement

          這里從我們team的代碼中來總結(jié)下常見的幾種找頁面元素的方法:
            (1)通過WebElement的ID
            如果某個WebElement提供了ID,
            <input type="text" name="passwd"id="passwd-id" />
            (2)通過WebElement的name查找:
            WebElement element = driver.findElement(By.name("passwd"));
            (3)通過WebElement的xpath查找:
            WebElement element =driver.findElement(By.xpath("http://input[@id='passwd-id']"));
            (4)通過WebElement的樣式查找:
            <div class="cheese"><span>Cheddar</span></div><divclass="cheese"><span>Gouda</span></div>
            可以通過這樣查找頁面元素:
            List<WebElement>cheeses = driver.findElements(By.className("cheese"));
            (5)通過超鏈接文本查找:
            <a>cheese</a>>
            那么可以通過這樣查找:
            WebElement cheese =driver.findElement(By.linkText("cheese"));

          posted on 2014-04-17 10:34 順其自然EVO 閱讀(1135) 評論(0)  編輯  收藏 所屬分類: selenium and watir webdrivers 自動化測試學(xué)習(xí)

          <2014年4月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 芦山县| 连州市| 庆云县| 许昌县| 苗栗市| 广东省| 山西省| 万山特区| 全南县| 堆龙德庆县| 金昌市| 南木林县| 太保市| 诸暨市| 陆丰市| 布尔津县| 黄骅市| 白水县| 兴宁市| 徐汇区| 江阴市| 盈江县| 武冈市| 浦东新区| 延川县| 绩溪县| 易门县| 嘉定区| 长顺县| 舒兰市| 潼南县| 泰州市| 宝丰县| 伊通| 灵石县| 土默特左旗| 收藏| 泰州市| 乌兰浩特市| 博白县| 岚皋县|