使用Microsoft Edge

时间:2016-02-01 20:50:35

标签: gulp protractor microsoft-edge angularjs-e2e cucumberjs

我使用CucumberJs和Gulp来运行我的e2e测试;但是,我需要针对Microsoft Edge运行它们。当我gulp protractor时,它会成功打开Chrome和Firefox,因为它们都不需要任何驱动程序,例如IEDriver.exeEdgeDriver.exe

如果有关如何使用Microsoft Edge设置Protractor的简单方法,是否有人可以指向一篇文章或显示以下步骤?

我试图通过在多个浏览器上执行测试来实现并行性;这就是我的配置:

 exports.config = {
  framework: 'cucumber',
  shardTestFiles: true,
  maxInstances: 2,
  multiCapabilities: [
    {
       'browserName': 'MicrosoftEdge',
       'platform': 'windows',
      }
    },
    {
      'browserName': 'firefox',
      loggingPrefs: {
        driver: 'DEBUG',
        server: 'INFO',
        browser: 'ALL'
      }
    }],
    //more configs here
}

我在上面实现了配置,使用这篇文章并行运行量角器e2e测试:http://blog.yodersolutions.com/run-protractor-tests-in-parallel/

如果您不知道如何设置Edge,那么IE driver的一个也会有帮助。

更新:

从此链接:https://msdn.microsoft.com/en-us/library/mt188085(v=vs.85).aspx;

  

使用Microsoft Edge启用WebDriver:

     

下载您选择的WebDriver语言绑定。目前C#和   支持Java Selenium语言绑定。

不使用Java或C# ,我只使用 Javascript(Protractor) ;这是否意味着Javascript currenlty的语言绑定不适用于Edge浏览器?

换句话说,我们目前无法使用Protractor(Javascript)自动化Edge浏览器?

任何帮助非常感谢,如果我发现有关设置Protractor with Edge的任何内容,我会更新这篇文章,现在已经在网上浏览了几个小时。

7 个答案:

答案 0 :(得分:1)

我在Linux中将Angular 9与Edge 89一起使用 以下配置对我有用

exports.config = {
  directConnect: true,
  chromeDriver: '/path/to/ms-edge/webdriver'
  capabilities: {
     browserName: 'chrome',
     chromeOptions: {
          binary: '/usr/bin/microsoft-edge'
     }
  },
},

可以找到官方WebDriver here 由于Edge使用Chromium引擎,因此我们可以重复使用所有chrome配置,而只需替换WebDriver和二进制路径。

答案 1 :(得分:0)

看起来Protractor人员正在为Protractor添加Edge支持。看看recently opened issue on GitHub

答案 2 :(得分:0)

经过一番努力,我让Protractor在我的Windows 10系统上使用Microsoft Edge。

注意:我使用的是Jasmine2框架而不是Cucumber,但我相信下面的步骤也适用于Cucumber。我稍后会尝试使用Cucumber并在此更新。

以下是步骤:

  1. 获取系统中使用的Microsoft EdgeHTML版本号。就我而言,它是15.15063。请记下此处的版本号。在这种情况下,它是15063。

    (问:如何获取Microsoft EdgeHTML版本号?
    答:边缘浏览器> ...>设置>关于这个应用程序)

  2. https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

    下载MicrosoftWebDriver.exe的正确版本

    在我的情况下,我下载了版本15063.如果您的版本错误,那么您可能会遇到错误,如此错误:

      

    "此版本的MicrosoftWebDriver.exe与已安装的Windows 10版本不兼容。"

  3. MicrosoftWebDriver.exe放在其他驱动程序所在的文件夹中:

    C:\Users\yourname\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\
    
  4. 调整conf.js文件。从本质上讲,这就是conf.js应具备的内容:

    seleniumAddress: 'http://localhost:4444/wd/hub',
    capabilities: // or multiCapabilities:
    {
        'browserName': "MicrosoftEdge"
    }
    
  5. 像这样启动webdriver-manager:

    C:\your\path>webdriver-manager start --edge C:\Users\yourname\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\MicrosoftWebDriver.exe
    
  6. 您已准备好在Edge浏览器上运行Protractor测试。

  7. 祝你好运!

答案 3 :(得分:0)

下载正确版本的EdgeHTML Webdriver(https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/),然后将conf.js设置为:

seleniumArgs: ['-Dwebdriver.edge.driver=C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe'],

Capabilities: {
      'browserName': 'MicrosoftEdge',
      'maxInstances': 1,
      'platformName': 'windows',
      'nativeEvents': false,
    }

答案 4 :(得分:0)

现在Mac操作系统支持Microsoft Edge。因此,要在Mac中进行设置,请按照以下步骤操作

  1. 根据Mac中配置的边缘浏览器版本,从以下链接下载MicrosoftEdge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

  2. 解压缩文件夹并将Unix可执行文件复制到以下路径 / usr / local / lib / node_modules / protractor / node_modules / webdriver-manager / selenium / MicrosoftWebDriver

  3. 在配置文件中添加SeleniumArgs属性和功能

seleniumArgs:['-Dwebdriver.edge.driver = / usr / local / lib / node_modules / protractor / node_modules / webdriver-manager / selenium / MicrosoftWebDriver'],

功能:{

browserName: 'MicrosoftEdge',
platformName: 'Mac OS X',
browserVersion: '79.0.309.65',
maxInstances: 1,
shardTestFiles: true,
elementScrollBehavior: 1,
nativeEvents: false

},

  1. 要使用Edge Session启动Web驱动程序,请使用以下命令。

java -jar -Dwebdriver.edge.driver = / usr / local / lib / node_modules / protractor / node_modules / webdriver-manager / selenium / MicrosoftWebDriver / Users // Desktop / Project / node_modules / webdriver-manager / selenium / Selenium -server-standalone-3.141.59.jar -port 4444

答案 5 :(得分:0)

  1. 在Windows中下载HTML版本> = 18的MicrosoftEdge Webdriver,然后执行以下步骤

打开命令提示符,发出以下命令,直到操作完成

DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
  1. 打开文件资源管理器并导航到C:\ Windows \ WinSxS并搜索MicrosoftWebDriver,它将显示两个结果,从amd64_microsoft-webdriver-server-components10.0.18362.1_none复制Webdriver并将其粘贴到

/c/Users/Administrator/AppData/Roaming/npm/node_modules/protractor/node_modules/webdriver-manager/selenium

(注意:使用git bash可以很容易地复制Webdriver)

  1. 在Edge浏览器的配置文件中,进行以下更改
seleniumArgs:['-Dwebdriver.edge.driver=C:\\Users\\Administrator\\AppData\\Roaming\\npm\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\MicrosoftWebDriver.exe'],

capabilities: {

    'browserName': 'MicrosoftEdge',
    'maxInstances': 1,
    'platformName': 'windows',
    'nativeEvents': false,
     shardTestFiles: true,
  },
  1. 打开命令提示符,然后导航到项目仓库并发出以下命令以开始边缘会话
webdriver-manager start --edge "C:\Users\Administrator\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\MicrosoftWebDriver.exe"

答案 6 :(得分:0)

Edge无法与Directconnect一起使用:是的。请参考以下示例。

directConnect: false,
 multiCapabilities: [
    {​​​​​
      browserName: 'chrome',
      chromeOptions: {​​​​​
        args: ['--disable-popup-blocking'],
      }​​​​​
        }​​​​​,
{​​​​​
      browserName: 'firefox'
        }​​​​​,
{​​​​​
      browserName: 'MicrosoftEdge'
        }​​​​​
  ],
jvmArgs: [
    '-Dwebdriver.chrome.driver=./src/driver/chromedriver_87.0.4280.20.exe',
    `-Dwebdriver.edge.driver=${edgeDriver}`,
    '-Dwebdriver.gecko.driver=./src/driver/geckodriver-v0.28.0.exe'
  ],

如果使用的是Mac,请在配置外部使用以下代码

const edgeDriver =
  process.platform === 'darwin'
    ? './src/driver/edgedriver_mac64_87.0.664.47/msedgedriver'
    : './src/driver/msedgedriver.exe';