小编nua*_*der的帖子

在页面上找不到量角器错误Angular

我正在尝试使用量角器(2.1.0)为我的Angular(1.4)站点设置End-2-End测试.Jasmine已安装且单元测试工作正常.当我运行量角器时,索引#/登录页面会在浏览器窗口中加载,但没有代码运行,并且量角器会报告此错误

失败:在页面上找不到Angular http://localhost/SpectrumGMWeb/index.html#/login:重试查找超出角度

我的量角器配置看起来像这样

exports.config = {
    allScriptsTimeout: 11000,
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    specs: [
        '*.js'
    ],
    rootElement:'html',
    capabilities: {
        'browserName': 'chrome'
    },
    baseUrl: 'http://localhost/SpectrumGMWeb/',
    framework: 'jasmine2',
    jasmineNodeOpts: {
        defaultTimeoutInterval: 30000
    },
};
Run Code Online (Sandbox Code Playgroud)

我的测试文件非常简单

describe('my app', function() {

    describe('login', function() {

        beforeEach(function() {
            browser.get('index.html#/login');
        });

        it('should render login page when user navigates to login page', function() {
            expect(true).toBe(true);
        });

    });
});
Run Code Online (Sandbox Code Playgroud)

ng-app ="main"在index.html的html元素上设置.该网站确实有效.

有任何想法吗?

jasmine angularjs protractor

10
推荐指数
3
解决办法
2万
查看次数

跨域时,JQuery ajax JSONP POST更改为GET

我有一个期待POST的WCF服务.使用Fiddler我发现在跨域情况下,我的POST请求被更改为GET,导致服务器出错405.

$.ajax({
    type: "POST",
    url: "http://blah/blah.svc/Test",
    data: JSON.stringify("{ 'WebUserID': 4 }"),
    dataType: "jsonp",  // from server
    contentType: "application/json; charset=utf-8", // to server
    success: function (data, status, xhr) {
        alert("success--");
    }
});
Run Code Online (Sandbox Code Playgroud)

任何人都可以对此有所了解吗?

谢谢

wcf jquery jsonp

5
推荐指数
2
解决办法
4556
查看次数

使用Payflow Pro重复付款 - 无效的交易类型

我已经建立了一个网站,该网站使用PayPal Payflow API使用具有定期付款服务的实时Payments Pro帐户处理付款交易.它的工作原理是首先请求安全令牌,然后提交事务.我使用托管页面(布局c)和透明重定向工作.我正在使用Payflow_dotNet dll,它使用payflowpro.paypal.com网址.但是,当我尝试通过将交易类型设置为"R"来提交交易以设置定期付款时,我收到以下错误

"结果3 - 安全令牌创建请求的无效事务类型"

以下是我正在使用的NVP字符串示例:

PARTNER[6]=PayPal&VENDOR[13]=me&USER[6]=username&PWD[8]=password&
TRXTYPE=R&ACTION=A&INVNUM=243&PROFILEREFERENCE=243&PROFILENAME[35]=Mark Groseth -- Science Center Fund&
START=09092014&TERM=0&PAYPERIOD=MONT&AMT[4]=1.01&CURRENCY[3]=USD&
CREATESECURETOKEN=Y&SECURETOKENID[32]=05831a20674941089f68d53b7184efff&TENDER=C&
SILENTTRAN=TRUE&RETURNURL[51]=myurl&CANCELURL[42]=myurl&ERRORURL[51]=myurl&URLMETHOD=POST&
BILLTOFIRSTNAME[4]=Mark&BILLTOLASTNAME[7]=Groseth&BILLTOSTREET[20]=1234 Somewhere st 55&BILLTOCITY[7]=Houston&BILLTOSTATE[2]=TX&BILLTOZIP[5]=77018&BILLTOEMAIL[13]=mark@home.com&BILLTOCOUNTRY[2]=US&
FIRSTNAME[4]=Mark&LASTNAME[7]=Groseth&STREET[20]=1234 Somewhere st 55&CITY[7]=Houston&STATE[2]=TX&ZIP[5]=77018&EMAIL[13]=mark@home.com&
COMMENT1[19]=Science Center Fund&L_NAME0[19]=Science Center Fund&L_DESC0[19]=Science Center Fund&L_COST0[4]=1.01&L_QTY0=1&ITEMAMT[4]=1.01
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?

我是否必须创建授权交易,然后以某种方式将其转换为定期付款资料?

paypal payflowpro recurring-billing

3
推荐指数
1
解决办法
975
查看次数

使用HttpBackend.whenGet的AngularJS单元测试不会返回预期结果

根据Angular docs for ngMock,$ httpBackend when方法应该拦截$ http服务请求并提供指定的响应.我假设模拟$ httpBackend方法将是同步的,以使测试更容易.但是result.test最终没有被定义.

describe('Http requests', function () {
    var scope, $httpBackend, constituents;

    beforeEach(module('main'));

    beforeEach(inject(function (_$httpBackend_, _constituents_) {
        constituents = _constituents_;
        $httpBackend = _$httpBackend_;
        $httpBackend.expectGET("App/Main/login.html").respond(200);
    }));

    it('Should get the constituents', function () {
        $httpBackend.whenGET(webServicesPath + "api/constituents/all-constituents").respond(200, { "test": true });
        var result = constituents.getAllConstituents();
        $httpBackend.flush();
        expect(result.$$state.value.test).toEqual(true);
    });

});
Run Code Online (Sandbox Code Playgroud)

我尝试使用$ httpBackend.flush(),但这会产生意想不到的后果......

错误:意外请求:GET App/Main/login.html

这意味着以某种方式调用了ui.routing服务.所以我来处理,它通过添加$httpBackend.expectGET...beforeEach.

为什么我甚至要使用flush方法? 似乎过于复杂.当与单元测试无关时,为什么会触发ui.routing?

作为参考,这是工厂使用的

app.factory('constituents', ['$http', '$log', function ($http, $log) {
    function getAllConstituents() {
        return $http.get(webServicesPath + "api/constituents/all-constituents").then(
            function (response) …
Run Code Online (Sandbox Code Playgroud)

unit-testing jasmine angularjs

0
推荐指数
1
解决办法
2094
查看次数