fix webdriver manual test cases execution issue
authorliuct <liuchengtao1982@gmail.com>
Mon, 11 Aug 2014 08:59:50 +0000 (16:59 +0800)
committerliuct <liuchengtao1982@gmail.com>
Mon, 11 Aug 2014 08:59:50 +0000 (16:59 +0800)
testkitlite/engines/mh.html [new file with mode: 0644]
testkitlite/engines/test_executer.py

diff --git a/testkitlite/engines/mh.html b/testkitlite/engines/mh.html
new file mode 100644 (file)
index 0000000..01632b7
--- /dev/null
@@ -0,0 +1,76 @@
+<html>\r
+<head>\r
+<title>Web Manual Test Harness</title>\r
+<meta name="viewport" content="width=device-width, initial-scale=1.0">\r
+<style type="text/css">\r
+body { font-family:Verdana; font-size:14px; margin:0;}\r
+#container-div {border: 0;margin:0 auto; width:100%;}\r
+#sidebar-left {border: 0;float:left; width:6px; height:100%;}\r
+#sidebar-right {border: 0;float:right; width:6px; height:100%;}\r
+#content-div {border: 0;margin:0 7px !important; height:100%;}\r
+.button {display:inline-block;min-width: 30px; max-width: 100px; margin-top: 3px;margin-bottom: 3px;padding: 3px}\r
+#back-bt, #forward-bt {max-width: 20px;}\r
+#case-info-area {border 0;text-align:left;}\r
+#test-entry, #refer-test-entry {font-size: 10px;color: red}\r
+#test-entry-area, #refer-test-entry-area {font-size: 10px;}\r
+#run-test-area, #result-area {text-align:right; margin:0 auto;padding:0;}\r
+iframe {border: 1px solid black;width: 100%; height: 600px;}\r
+</style>\r
+<script>\r
+function run_test(){\r
+    document.getElementById("test-area").src = document.getElementById("test-entry").textContent;\r
+};\r
+\r
+function run_refer_test(){\r
+    document.getElementById("test-area").src = document.getElementById("refer-test-entry").textContent;\r
+};\r
+\r
+function result_handler(){\r
+    try{\r
+        window.stop();\r
+    } catch(e) {\r
+        document.execCommand('Stop');\r
+    }\r
+    window.stop();\r
+    document.getElementById("case-info-area").className = this.name\r
+};\r
+\r
+function init_mh(){\r
+    document.getElementById("case-info-area").className = "READY";\r
+    document.getElementById("run-test-bt").addEventListener("click", run_test, false);\r
+    document.getElementById("run-refer-test-bt").addEventListener("click", run_refer_test, false);\r
+    document.getElementById("back-bt").addEventListener("click", result_handler, false);\r
+    document.getElementById("pass-bt").addEventListener("click", result_handler, false);\r
+    document.getElementById("fail-bt").addEventListener("click", result_handler, false);\r
+    document.getElementById("block-bt").addEventListener("click", result_handler, false);\r
+    document.getElementById("forward-bt").addEventListener("click", result_handler, false);\r
+    document.getElementById("done-bt").addEventListener("click", result_handler, false);\r
+};\r
+</script>\r
+</head>\r
+<body onload="init_mh()">\r
+<div id="container-div">\r
+    <div id="sidebar-left"></div>\r
+    <div id="sidebar-right"></div>\r
+    <div id="content-div">\r
+        <div id="run-test-area">\r
+            <input type="button" id="back-bt" name="BACK" class="button" value="<"></input>\r
+            <input type="button" id="run-test-bt" class="button" value="Run Test"></input>\r
+            <input type="button" id="run-refer-test-bt" class="button" value="Run Refer Test"></input>\r
+            <input type="button" id="forward-bt" name="FORWARD" class="button" value=">"></input>\r
+        </div>\r
+        <div id=result-area>\r
+                <input type="button" id="pass-bt" name="PASS" class="button" value="PASS"></input>\r
+                <input type="button" id="fail-bt" name="FAIL" class="button" value="FAIL"></input>\r
+                <input type="button" id="block-bt" name="BLOCK" class="button" value="BLOCK"></input>\r
+                <input type="button" id="done-bt" name="DONE" class="button" value="DONE"></input>\r
+        </div>\r
+        <div id="case-info-area">\r
+            <div id="test-entry-area">Test Entry: <span id="test-entry">http://www.baidu.com</span></div>\r
+            <div id="refer-test-entry-area">Refer Test Entry: <span id="refer-test-entry">http://www.sina.com</span></div>\r
+        </div>\r
+        <iframe id="test-area"></iframe>\r
+    </div>\r
+</div>\r
+</body>\r
+</html>\r
index cb04ff9..1807d97 100644 (file)
@@ -235,12 +235,16 @@ class TestExecuter:
                 break
 
     def __checkPageNotFound(self, page_url=None):
-        if self.web_driver.current_url.find('data:text/html,chromewebdata') >= 0:
-            self.TE_LOG.debug("Page not found: %s" %
+        try:
+            if self.web_driver.current_url.find('data:text/html,chromewebdata') >= 0:
+                self.TE_LOG.debug("Page not found: %s" %
                               self.web_driver.current_url)
+                return False
+            else:
+                return True
+        except Exception, e:
+            self.TE_LOG.error("Failed to get current url")
             return False
-        else:
-            return True
 
     def __runRefTests(self, haha=None, kkkk=None):
         for i_case in self.tests_json['cases']:
@@ -489,7 +493,6 @@ class TestExecuter:
                 break
 
     def __runTests(self, haha=None, kkkk=None):
-        print 'xxx',os.environ['TEST_PLATFORM']
         for i_case in self.tests_json['cases']:
             i_case['result'] = STR_NOTRUN
         if self.set_exetype == "manual":