gpt4 book ai didi

javascript - Protractor : how to compare the text content of the same web element before and after clicking on a button

转载 作者:搜寻专家 更新时间:2023-11-01 04:52:02 24 4
gpt4 key购买 nike

我想在我的 angularJS 应用程序中测试过滤功能。事实上,当我点击过滤器时,页面上显示的搜索结果数量应该会减少到目前为止,这是我的代码:

    element(by.id('foundNumber')).getText().then (function(text){console.log(text); })
element(by.repeater('term in facets.uproctype').row(0)).click ()
element(by.id('foundNumber')).getText().then (function(text){console.log(text); })

这是我的控制台日志:

Using the selenium server at http://localhost:4444/wd/hub
6209
6195
....

我不知道如何在期望行中比较这两个值,因为我不能在它们的函数中使用它们。有帮助吗?

谢谢齐德

最佳答案

我相信您必须嵌套 then 函数以确保原始值可用。

element(by.id('foundNumber')).getText().then( function(original_text) {

element(by.repeater('term in facets.uproctype').row(0)).click ();

element(by.id('foundNumber')).getText().then( function(new_text){
expect(original_text).not.toBe(new_text);
});

});

此链接也可能有帮助。 https://code.google.com/p/selenium/wiki/WebDriverJs#Control_Flows

关于javascript - Protractor : how to compare the text content of the same web element before and after clicking on a button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21909220/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com