加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ajax – 在使用appium执行量角器脚本时等待异步脚本结果超时

发布时间:2020-12-15 22:53:05 所属栏目:百科 来源:网络整理
导读:在量角器中运行多个测试时遇到问题:60010秒后等待异步脚本结果超时 在登录脚本之后执行的教程脚本代码: 这里的代码我在A Code proposed in another question的配置文件中使用,但它没有解决我的问题! onPrepare: function() { return browser.getProcessed
在量角器中运行多个测试时遇到问题:60010秒后等待异步脚本结果超时
在登录脚本之后执行的教程脚本代码:

这里的代码我在A Code proposed in another question的配置文件中使用,但它没有解决我的问题!

onPrepare: function() {
  return browser.getProcessedConfig().then(function(config) {
    var browserName = config.capabilities.browserName;
    browser.manage().timeouts().setScriptTimeout(60000);

  });

PS:即使我为元素放置了错误的位置,我也有超时错误,而且找不到这个元素!好像那行代码“点击进入教程按钮”永远不会被执行

>是因为教程进行ajax调用吗?


这是我的HTML代码:

</div></md-card-content> </md-card><!-- end ngIf: !expandChart --> </div> </div> </div></md-content> </div></div> <!-- Google Analytics: change UA-XXXXX-X to be your site's ID --> <!--<script>--> <!--!function(A,n,g,u,l,a,r){A.GoogleAnalyticsObject=l,A[l]=A[l]||function(){--> <!--(A[l].q=A[l].q||[]).push(arguments)},A[l].l=+new Date,a=n.createElement(g),--> <!--r=n.getElementsByTagName(g)[0],a.src=u,r.parentNode.insertBefore(a,r)--> <!--}(window,document,'script','https://www.google-analytics.com/analytics.js','ga');--> <!--ga('create','UA-XXXXX-X');--> <!--ga('send','pageview');--> <!--</script>--> <script src="scripts/vendor.js"></script> <script src="cordova.js"></script> <script src="scripts/scripts.js"></script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"></script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script> <div class="introjs-overlay" style="top: 0;bottom: 0; left: 0;right: 0;position: fixed;opacity: 0.8;"></div><div class="introjs-helperLayer " style="width: 538px; height:366px; top:64px;left: 195px;"></div><div class="introjs-tooltipReferenceLayer" style="width: 538px; height:366px; top:64px;left: 195px;"><div class="introjs-tooltip" style="left: 546px;"><div class="introjs-tooltiptext">Watchlist view. Swipe the row in the grid to the left to show the delete action.</div><div class="introjs-bullets"><ul><li><a class="active" href="javascript:void(0);" data-stepnumber="1">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="2">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="3">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="4">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="5">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="6">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="7">&nbsp;</a></li><li><a href="javascript:void(0);" data-stepnumber="8">&nbsp;</a></li></ul></div><div class="introjs-progress" style="display: none;"><div class="introjs-progressbar" style="width:12.5%;"></div></div><div class="introjs-arrow left" style="display: inherit;"></div><div class="introjs-tooltipbuttons"><a class="introjs-button introjs-skipbutton" href="javascript:void(0);">Don't show it again!</a><a href="javascript:void(0);" class="introjs-button introjs-prevbutton introjs-disabled" tabindex="-1">Previous</a><a href="javascript:void(0);" class="introjs-button introjs-nextbutton">Next</a></div></div></div></body></html>?

解决方法

1.关于路线检查

如果在第一个规范之后,用户登录并且路线已更改.确保在执行任何测试之前导航所有内容.

expect(browser.getCurrentUrl()).toContain('#/the_route_of_logged_in'); 
// '#/' is just illustration. You can remove it to make it shorter
// => like this ...toContain('the_route_of_logged_in');

2.关于点击教程

browser.wait(EC.elementToBeClickable(tutorial),10000);

在尝试点击它之前,使用EC进行可点击按钮的浏览器.(看起来你在这里有好的方法)

=>总结你可以尝试一下:

'user strict';

var EC = protractor.ExpectedConditions;

describe('tutorials',function () {

    it('should make click into tutorial button',function () {

        expect(browser.getCurrentUrl()).toContain('the_route_of_logged_in');

        var tutorial = $('.introjs-nextbutton'); 
        browser.wait(EC.elementToBeClickable(tutorial),8000,'Timed out');
        tutorial.click();

        browser.sleep(8080); // regardless we are not reaching this point. But I will suggest to reduce this sleep time like 1000 (1s).
    });
});

3.(可选)如果2点以上没有帮助

在您的所有规范login-spec.js和tutorial-spec.js中.添加process.nextTick(已完成);在afterAll()块中确保在规范之后没有任何Jasmine Reporters被卡住.

describe('foo',function(){

  afterAll(function(done){
    process.nextTick(done);
  });  

  it('should bar...',function() {});
}

附:请注意,如果我的建议/方法有所帮助,我完全不知道.因为使用e2e-test进行调试总是很痛苦…因为我们总是不知道“错误来自哪里”.所以我所能做的就是给你建议.
(有时我只花了几个小时来观察浏览器识别e2e测试问题的行为)

并且不要将我的代码复制到您的代码中.我用你提供的图片输入它,我可以在那里做一些拼写错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读