2017-04-12 164 views
1

我嘗試在Safari上運行量角器測試「角不能在頁面https://angularjs.org/找到」,但我有一個問題,甚至有一個官方的例子(http://www.protractortest.org/我附在我的conf.js和todo-spec.js文件下面)。運行在Safari量角器測試,說

當我設置browser.ignoreSynchronization = true; (What is browser.ignoreSynchronization in protractor?)然後測試工作,但我不能利用量角器。

https://angularjs.org/使用角1.6.4


  • 日誌從運行測試:

    $ node ./node_modules/protractor/built/cli.js conf.js --browser safari 
    (node:5778) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. 
    [09:49:28] I/hosted - Using the selenium server at http://MAC_IP:4444/wd/hub 
    [09:49:28] I/launcher - Running 1 instances of WebDriver 
    Started 
    [09:49:41] E/protractor - Could not find Angular on page https://angularjs.org/ : angular never provided resumeBootstrap 
    F 
    
    Failures: 
    1) angularjs homepage todo list should add a todo 
        Message: 
        Failed: Angular could not be found on the page https://angularjs.org/. If this is not an Angular application, you may need to turn off waiting for Angular. Please see https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load 
        Stack: 
        Error: Angular could not be found on the page https://angularjs.org/. If this is not an Angular application, you may need to turn off waiting for Angular. Please see https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load 
         at /home/tester/proj/js/node_modules/protractor/built/browser.js:506:23 
         at ManagedPromise.invokeCallback_ (/home/tester/proj/js/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14) 
         at TaskQueue.execute_ (/home/tester/proj/js/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14) 
         at TaskQueue.executeNext_ (/home/tester/proj/js/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21) 
         at asyncRun (/home/tester/proj/js/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2775:27) 
         at /home/tester/proj/js/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7 
         at process._tickCallback (internal/process/next_tick.js:103:7) 
        From: Task: Run it("should add a todo") in control flow 
         at Object.<anonymous> (/home/tester/proj/js/node_modules/jasminewd2/index.js:79:14) 
        From asynchronous test: 
        Error 
         at Suite.<anonymous> (/home/tester/proj/js/todo-spec.js:2:3) 
         at Object.<anonymous> (/home/tester/proj/js/todo-spec.js:1:1) 
         at Module._compile (module.js:571:32) 
         at Object.Module._extensions..js (module.js:580:10) 
         at Module.load (module.js:488:32) 
         at tryModuleLoad (module.js:447:12) 
    
    1 spec, 1 failure 
    Finished in 11.68 seconds 
    [09:49:41] I/launcher - 0 instance(s) of WebDriver still running 
    [09:49:41] I/launcher - safari #01 failed 1 test(s) 
    [09:49:41] I/launcher - overall: 1 failed spec(s) 
    [09:49:41] E/launcher - Process exited with error code 1 
    

  • 的webdriver的管理器開始升OGS:

    $ ./node_modules/protractor/bin/webdriver-manager start 
    [09:49:21] I/start - java -Dwebdriver.chrome.driver=/Users/tester/proj/js/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29 -Dwebdriver.gecko.driver=/Users/tester/proj/js/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.15.0 -jar /Users/tester/proj/js/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.3.1.jar -port 4444 
    [09:49:21] I/start - seleniumProcess.pid: 95779 
    09:49:21.673 INFO - Selenium build info: version: '3.3.1', revision: '5234b32' 
    09:49:21.673 INFO - Launching a standalone Selenium Server 
    2017-04-12 09:49:21.724:INFO::main: Logging initialized @358ms to org.seleniumhq.jetty9.util.log.StdErrLog 
    09:49:21.777 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped: 
    registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC 
    09:49:21.777 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped: 
    registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC 
    09:49:21.777 INFO - Driver class not found: com.opera.core.systems.OperaDriver 
    09:49:21.777 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped: 
    Unable to create new instances on this machine. 
    09:49:21.778 INFO - Driver class not found: com.opera.core.systems.OperaDriver 
    09:49:21.778 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered 
    2017-04-12 09:49:21.823:INFO:osjs.Server:main: jetty-9.2.20.v20161216 
    2017-04-12 09:49:21.849:INFO:osjsh.ContextHandler:main: Started [email protected]{/,null,AVAILABLE} 
    2017-04-12 09:49:21.880:INFO:osjs.AbstractConnector:main: Started [email protected]{HTTP/1.1,[http/1.1]}{0.0.0.0:4444} 
    2017-04-12 09:49:21.881:INFO:osjs.Server:main: Started @515ms 
    09:49:21.881 INFO - Selenium Server is up and running 
    09:49:28.191 INFO - SessionCleaner initialized with insideBrowserTimeout 0 and clientGoneTimeout 1800000 polling every 180000 
    09:49:28.214 INFO - Executing: [new session: Capabilities [{count=1, browserName=safari}]]) 
    09:49:28.235 INFO - Creating a new session for Capabilities [{count=1, browserName=safari}] 
    09:49:29.500 INFO - Detected dialect: OSS 
    09:49:29.515 INFO - Done: [new session: Capabilities [{count=1, browserName=safari}]] 
    09:49:29.533 INFO - Executing: [set script timeout: 11000]) 
    09:49:29.541 INFO - Done: [set script timeout: 11000] 
    09:49:29.715 INFO - Executing: [get: about:blank]) 
    09:49:29.954 INFO - Done: [get: about:blank] 
    09:49:29.964 INFO - Executing: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" + window.name;window.location.replace("https://angularjs.org/");, []]) 
    09:49:29.994 INFO - Done: [execute script: window.name = "NG_DEFER_BOOTSTRAP!" + window.name;window.location.replace("https://angularjs.org/");, []] 
    09:49:30.005 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.040 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.049 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.054 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.064 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.090 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.102 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.107 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.120 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.141 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.149 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.154 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.161 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.191 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.199 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.204 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.212 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.241 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.250 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.256 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.273 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.442 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.451 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.455 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.475 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.492 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.500 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.505 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.512 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.543 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.549 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.553 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.560 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.591 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.600 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.604 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.610 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.647 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.653 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.657 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.662 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.698 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.704 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.742 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.750 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.754 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.761 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.797 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.803 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.844 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.851 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.856 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.863 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.897 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.903 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.908 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.915 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.946 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:30.956 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:30.996 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:31.002 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:31.006 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:31.013 INFO - Executing: [execute script: return window.location.href;, []]) 
    09:49:31.056 INFO - Done: [execute script: return window.location.href;, []] 
    09:49:31.062 INFO - Executing: [execute async script: try { return (function (attempts, ng12Hybrid, asyncCallback) { 
        var callback = function(args) { 
        setTimeout(function() { 
         asyncCallback(args); 
        }, 0); 
        }; 
        var check = function(n) { 
        try { 
         if (!ng12Hybrid && window.getAllAngularTestabilities) { 
         callback({ver: 2}); 
         } else if (window.angular && window.angular.resumeBootstrap) { 
         callback({ver: 1}); 
         } else if (n < 1) { 
         if (window.angular) { 
          callback({message: 'angular never provided resumeBootstrap'}); 
         } else { 
          callback({message: 'retries looking for angular exceeded'}); 
         } 
         } else { 
         window.setTimeout(function() {check(n - 1);}, 1000); 
         } 
        } catch (e) { 
         callback({message: e}); 
        } 
        }; 
        check(attempts); 
    }).apply(this, arguments); } 
    catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10, false]]) 
    09:49:41.340 INFO - Done: [execute async script: try { return (function (attempts, ng12Hybrid, asyncCallback) { 
        var callback = function(args) { 
        setTimeout(function() { 
         asyncCallback(args); 
        }, 0); 
        }; 
        var check = function(n) { 
        try { 
         if (!ng12Hybrid && window.getAllAngularTestabilities) { 
         callback({ver: 2}); 
         } else if (window.angular && window.angular.resumeBootstrap) { 
         callback({ver: 1}); 
         } else if (n < 1) { 
         if (window.angular) { 
          callback({message: 'angular never provided resumeBootstrap'}); 
         } else { 
          callback({message: 'retries looking for angular exceeded'}); 
         } 
         } else { 
         window.setTimeout(function() {check(n - 1);}, 1000); 
         } 
        } catch (e) { 
         callback({message: e}); 
        } 
        }; 
        check(attempts); 
    }).apply(this, arguments); } 
    catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [10, false]] 
    09:49:41.351 INFO - Executing: [delete session: 199560b8-0691-456f-927e-15991a47acea]) 
    09:49:41.446 INFO - Done: [delete session: 199560b8-0691-456f-927e-15991a47acea] 
    

  • conf.js:

    exports.config = { 
        framework: 'jasmine2', 
        seleniumAddress: 'http://MAC_IP:4444/wd/hub', 
        specs: ['todo-spec.js'] 
    }; 
    
  • 待辦事項-spec.js:

    describe('angularjs homepage todo list', function() { 
        it('should add a todo', function() { 
        browser.get('https://angularjs.org'); 
    
        element(by.model('todoList.todoText')).sendKeys('write first protractor test'); 
        element(by.css('[value="add"]')).click(); 
    
        var todoList = element.all(by.repeater('todo in todoList.todos')); 
        expect(todoList.count()).toEqual(3); 
        expect(todoList.get(2).getText()).toEqual('write first protractor test'); 
    
        // You wrote your first test, cross it off the list 
        todoList.get(2).element(by.css('input')).click(); 
        var completedAmount = element.all(by.css('.done-true')); 
        expect(completedAmount.count()).toEqual(2); 
        }); 
    }); 
    
+0

您正在使用哪個版本的Safari? 設置'browser.ignoreSynchronization = TRUE'會告訴量角器不要等角度來完成加載頁/角內容。默認情況下,量角器會詢問Angular是否完成加載所需的數據/過程。 – wswebcreation

+0

Safari瀏覽器10.1(11603.1.30.0.34) – flig

回答

0

我知道在Safari 10中存在一些異步的問題,請參閱量角器git中的this comment。它描述了Safari桌面的解決方法。

希望它有助於/給你足夠的信息。

+0

這帶來作爲ignoreSynchronization相同的效果。我需要參加一些事件或類似的事情...... – flig

相關問題