Opening a file with protractor

前端 未结 4 1762
挽巷
挽巷 2020-12-08 16:15

Every protractor example I can find on the internet seems to use browser.get with a web URI.

browser.get(\'http://localhost:8000\');
         


        
4条回答
  •  醉酒成梦
    2020-12-08 16:28

    I had the same error and fixed by applying Michael Radionov's fix but removing the baseUrl. Here is my setup:

    protractor.config.js:

    exports.config = {
    
      capabilities: {
        browserName: 'chrome'
      },
    
      specs: [
        '*.js'
      ],
    
      onPrepare: function() {
        // By default, Protractor use data:text/html, as resetUrl, but 
        // location.replace from the data: to the file: protocol is not allowed
        // (we'll get ‘not allowed local resource’ error), so we replace resetUrl with one
        // with the file: protocol (this particular one will open system's root folder)
        browser.ignoreSynchronization = true;
        browser.waitForAngular();
        browser.sleep(500); 
        browser.resetUrl = 'file:///';
      }
    
    };
    

    e2etest.js:

    'use strict';
    
    describe("Buttons' tests are started", function() {
    
        it('Should retrieve 20 records into table', function() {
    
            browser.get('file:///C:/Users/path_to_file/index.html');
    
            /* Test codes here */
    
        });
    
    });
    

提交回复
热议问题