黄瓜硒没有设置角度js webapp中的值

时间:2017-03-13 23:20:52

标签: angularjs selenium cucumber

我正在为我的公司整理一个小型培训网络应用程序来试验TDD方法。我是如此新鲜的角js不知道为什么我的黄瓜硒没有找到正确的元素和插入适当的值。 希望有人可以打我的头,告诉我我错过了什么

我的功能文件

  Scenario: Add two positive numbers
  Given I am on the demo page
  When I add the numbers 2 and 3
  Then the result is 5

我的网页有以下div

 <div class="well well-lg text-center" ng-controller="additionController">
    <h2>Addition</h2>
    <form class="form-horizontal" role="form">
        <div class="form-group">
            <label class="col-sm-4 control-label">First Number: </label>
            <div class="col-sm-8">
                <input id="adder-first-number" class="form-control" ng-model="firstNumber" type="text"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-4 control-label">Second Number: </label>
            <div class="col-sm-8">
                <input id="adder-second-number" class="form-control" ng-model="secondNumber" type="text"/>
            </div>
        </div>
        <div class="form-group">
            <button id="adder-button" class="btn btn-lg btn-success" ng-click="add()">Add</button>
        </div>
    </form>


        <span id="adder-result" style="font-size: 500%">{{additionResult}}</span>
  </div> 

运行maven验证我正在

  2017-03-13 16:00:10.867 plugin-container[2745:390865] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x513f, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
 2017-03-13 16:00:10.869 plugin-container[2745:390865] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x501b, name = 'com.apple.CFPasteboardClient'
        See /usr/include/servers/bootstrap_defs.h for the error codes.
2017-03-13 16:00:10.869 plugin-container[2745:390865] void __CFPasteboardSetup() : Failed to allocate communication port for com.apple.CFPasteboardClient; this is likely due to sandbox restrictions
!!!!!!!! x=2 y=3
>>>>>>>>first number=2 y=3

  Scenario: Add two positive numbers # net/xeric/demos/adder.feature:3
   Given I am on the demo page      # DemoSteps.i_am_on_the_demo_page()
   When I add the numbers 2 and 3   #  DemoSteps.i_add_the_numbers_and(int,int)
  org.openqa.selenium.NoSuchElementException: Unable to locate element: #adder\-first\-number
  For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
  Build info: version: '3.2.0', revision: '8c03df6b79', time: '2017-02-23 10:51:31 +0000'
  System info: host: 'Peters-MacBook-Pro.local', ip: 'fe80:0:0:0:22c9:d0ff:fe44:908d%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_101'
  Driver info: org.openqa.selenium.firefox.FirefoxDriver
  Capabilities [{moz:profile=/var/folders/2m/csls0wzx7mnfx5s83c_d47bm0000gn/T/rust_mozprofile.K71LPcrDJ8Gw, rotatable=false, timeouts={implicit=0, page load=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=52.0, platformVersion=15.6.0, moz:processID=2740, browserName=firefox, platformName=darwin}]
  Session ID: 304ff3e9-59b4-a74f-8386-499bdc5318c3
  *** Element info: {Using=id, value=adderfirstnumber}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:420)
    at org.openqa.selenium.By$ById.findElement(By.java:218)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
    at net.xeric.demos.pages.DemoPage.addNumbers(DemoPage.java:33)
    at net.xeric.demos.steps.DemoSteps.i_add_the_numbers_and(DemoSteps.java:35)
    at ✽.When I add the numbers 2 and 3(net/xeric/demos/adder.feature:5)

我的步骤文件从args上面的输出中清楚地显示以下是2和3

    @When("^I add the numbers (-?\\d+) and (-?\\d+)$")
public void i_add_the_numbers_and(int arg1, int arg2) throws Throwable     {
    System.out.println("!!!!!!!! x=" + arg1 + " y=" + arg2);
    demoPage.addNumbers(arg1, arg2);
}

DemoPage.java有

 public void addNumbers(int x, int y) {
    System.out.println(">>>>>>>>first number=" + x + " y="+y);
    driver.findElement(By.id("adder-first-number")).sendKeys(Integer.toString(x));
    driver.findElement(By.id("adder-second-number")).sendKeys(Integer.toString(y));
    driver.findElement(By.id("adder-button")).click();
 }

JUST实现了FF屏幕快速闪烁。这是什么意思?

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Mar 14 08:36:47 PDT 2017
There was an unexpected error (type=Not Found, status=404).
No message available

1 个答案:

答案 0 :(得分:0)

问题似乎与Firefox selenium有关。当使用chrome和chrome驱动程序时,我能够完成所有工作。有一天我会回去看看我是否可以在FF,IE,Safari中使用它