<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    qileilove

    blog已經轉移至github,大家請訪問 http://qaseven.github.io/

    Selenium 利用javascript 控制滾動條

      以下備注所用test.html 的代碼(我也是在網上找的,簡單的修改顯示文字而已),供大家使用:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
    <html xmlns=http://www.w3.org/1999/xhtml>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Selenium Study</title>
    <script language="JavaScript">
    function check(){
    var clientHeight = document.getElementById('text').clientHeight;
    var scrollTop    = document.getElementById('text').scrollTop;
    var scrollHeight = document.getElementById('text').scrollHeight;
    if(clientHeight + scrollTop < scrollHeight){
    alert("Please view top news terms !"); return false;
    }else{
    alert("Thanks !");
    }
    }
    function set()
    {
    document.getElementById('text').scrollTop=10000;
    }
    </script>
    </head>
    <body>
    <form id="form1" method="post" onsubmit="return check();">
    <textarea id="text" name="text" cols="70"  rows="14">
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    </textarea><br /><br />
    <input type="submit" id="submit" name="submit" value="Submit" />
    </form>
    </body>
    </html>

     < xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" />

      在工作中,遇到這樣的問題,注冊時的法律條文需要閱讀,判斷用戶是否閱讀的標準是:滾動條是否拉到最下方。以下是我模擬的2種情況:

      1.滾動條在上方時,點擊submit用戶,提示:please view top new terms!

      2.滾動條在最下方,點擊submit用戶,提示:Thanks!

      以上如果是手動測試顯然很簡單,那么如何用selenium測試呢。

      經過IDE錄制,發現拖動滾動條的動作并沒有錄制下來!那么能想到的方法只有利用javascript來設置了。

      Baidu后得到的知識是:

      <body   onload= "document.body.scrollTop=0 ">


      也就是說如果scrollTop=0 時,滾動條就會默認在最上方

      <body   onload= "document.body.scrollTop=100000 ">

      也就是說如果scrollTop=100000 時,滾動條就會默認在最下方

      通過以上,以及學習的selenium調用javascript的知識:

      在javascript中調用頁面上的元素的方法

      this.browserbot.getUserWindow().document.getElementById('text')

      這樣設置元素的屬性就很簡單了

      this.browserbot.getUserWindow().document.getElementById('text').scrollTop=10000"

      經過修改的IDE腳本

      以下備注所用test.html 的代碼(我也是在網上找的,簡單的修改顯示文字而已),供大家使用:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
    <html xmlns=http://www.w3.org/1999/xhtml>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Selenium Study</title>
    <script language="JavaScript">
    function check(){
    var clientHeight = document.getElementById('text').clientHeight;
    var scrollTop    = document.getElementById('text').scrollTop;
    var scrollHeight = document.getElementById('text').scrollHeight;
    if(clientHeight + scrollTop < scrollHeight){
    alert("Please view top news terms !"); return false;
    }else{
    alert("Thanks !");
    }
    }
    function set()
    {
    document.getElementById('text').scrollTop=10000;
    }
    </script>
    </head>
    <body>
    <form id="form1" method="post" onsubmit="return check();">
    <textarea id="text" name="text" cols="70"  rows="14">
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    Selenium IDE is the a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.
    </textarea><br /><br />
    <input type="submit" id="submit" name="submit" value="Submit" />
    </form>
    </body>
    </html>

    posted on 2013-09-11 11:35 順其自然EVO 閱讀(392) 評論(0)  編輯  收藏 所屬分類: selenium and watir webdrivers 自動化測試學習

    <2013年9月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    293012345

    導航

    統計

    常用鏈接

    留言簿(55)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: h片在线播放免费高清| 日本中文字幕免费看| 一个人免费日韩不卡视频| 中文字幕一精品亚洲无线一区| 大桥未久亚洲无av码在线| 97无码免费人妻超级碰碰碰碰| 亚洲精品亚洲人成在线观看麻豆 | 亚洲熟妇AV日韩熟妇在线| 亚州免费一级毛片| 亚洲国产精品网站久久| 麻豆最新国产剧情AV原创免费| 亚洲免费视频观看| 最近的中文字幕大全免费版| 亚洲精品无码中文久久字幕| 国产一级理论免费版| 无遮挡国产高潮视频免费观看| 中文字幕亚洲电影| 免费看少妇高潮成人片| 久久久久亚洲av无码专区| 精品久久8x国产免费观看| 亚洲一本到无码av中文字幕| 国产免费人成在线视频| 国产美女视频免费观看的网站| 亚洲第一成年男人的天堂| 全免费毛片在线播放| 色噜噜狠狠色综合免费视频| 中文字幕亚洲一区二区va在线| 无码av免费网站| 亚洲精品无码一区二区| 久久久久亚洲精品无码网址| 无码人妻丰满熟妇区免费| 亚洲 日韩经典 中文字幕| 亚洲天堂中文字幕在线| 99re6热视频精品免费观看| 亚洲精品国产摄像头| 亚洲午夜久久久久久久久电影网| 18未年禁止免费观看| 亚洲AV无码一区二区三区牲色| 亚洲人成网77777色在线播放| 真人做人试看60分钟免费视频| 国产青草亚洲香蕉精品久久|