首页 \ 问答 \ 如何在量角器中识别具有两个预期条件的特定元素(How to identify specific element with two expect conditions in protractor)

如何在量角器中识别具有两个预期条件的特定元素(How to identify specific element with two expect conditions in protractor)

在我的应用程序中,我想通过使用它的名称所有者名称来选择特定通知。 我怎么能在量角器中做到这一点? 我添加了屏幕截图,我想从列表中选择“Sonal Dalal的Test Auction1”通知。 第二个屏幕截图显示了通过“Sonal Dalal测试Auction1”的页面代码

在此处输入图像描述

在此处输入图像描述

我在spec文件中尝试了以下代码:

Auction.AuctionNotiNewInv.isDisplayed().then(function(){
        Auction.NotificationTitle.get(0).isDisplayed().then(function(){
            Auction.NotificationTitle.count().then(function(Count){
                console.log(Count);
                var NotifTitleCount = Count;
                for(var i=0; i < NotifTitleCount; i++) {
                    Auction.NotificationTitle.get(i).isDisplayed().then(function(){
                        Auction.NotifAuctioneer.isDisplayed().then(function(IsDisplayed){
                        if(IsDisplayed)
                            Auction.NotificationTitle.get(i).click();
                         else
                            console.log('New Auction invitation is not displayed.');

                        });
                    });
                }
            });
        });
    });

PO文件如下:

this.AuctionNotiNewInv = element(by.cssContainingText('.md-subheader-inner','NEW INVITATIONS'));
this.NotificationTitle = element.all(by.cssContainingText('.title.ng-binding',data.AuctionName));
this.NotifAuctioneer = element(by.cssContainingText('.subtitle.ng-binding',data.NewFirstName + ' ' + data.NewLastName));

但是上面的代码返回我count = 4,因为页面上有其他对象具有相同属性“NotificationTitle”但它不是通知列表的一部分。 任何人都可以建议我使用expect函数来处理这个问题吗?


In my application I want to select specific notification by using it's name AND owner name. How can I do that in protractor? I have added screenshot and I want to select notification "Test Auction1 by Sonal Dalal" from the list. Second screenshot shows the page code for notification "Test Auction1 by Sonal Dalal"

enter image description here

enter image description here

I have tried below code in spec file:

Auction.AuctionNotiNewInv.isDisplayed().then(function(){
        Auction.NotificationTitle.get(0).isDisplayed().then(function(){
            Auction.NotificationTitle.count().then(function(Count){
                console.log(Count);
                var NotifTitleCount = Count;
                for(var i=0; i < NotifTitleCount; i++) {
                    Auction.NotificationTitle.get(i).isDisplayed().then(function(){
                        Auction.NotifAuctioneer.isDisplayed().then(function(IsDisplayed){
                        if(IsDisplayed)
                            Auction.NotificationTitle.get(i).click();
                         else
                            console.log('New Auction invitation is not displayed.');

                        });
                    });
                }
            });
        });
    });

And PO file is as below:

this.AuctionNotiNewInv = element(by.cssContainingText('.md-subheader-inner','NEW INVITATIONS'));
this.NotificationTitle = element.all(by.cssContainingText('.title.ng-binding',data.AuctionName));
this.NotifAuctioneer = element(by.cssContainingText('.subtitle.ng-binding',data.NewFirstName + ' ' + data.NewLastName));

but above code returns me count = 4, as there are other objects on page which has same property of "NotificationTitle" but it's not a part of notification list. Can anybody suggest me another way to handle this using expect function?


原文:https://stackoverflow.com/questions/40670909
更新时间:2019-12-03 08:18

相关问答

更多

部署python应用程序,并作为流程安装python,git,virtualenv在Windows上的一部分(Deploy python app and as part of process install python, git, virtualenv on windows)

我们做了一些非常类似的事情。 这就是我们所做的。 创建一个安装python的安装程序(我们使用NSIS http://nsis.sourceforge.net/Main_Page )。 安装python之后,我们运行一个执行其余步骤的python脚本。 一旦你的目标上有python,剩下的步骤就是小菜一碟。 We done something very similar to this. Here's what we did. Create an installer (we used NSIS h

Eclipse - Pydev代码完成(无法创建选定的首选项页面)(Eclipse - Pydev Code Completion (Unable to create the selected preference page))

对于那个很抱歉。 这是PyDev 6.3.1中的一个错误。 我将确保它已在PyDev 6.3.2中修复。 Sorry about that. This is a bug in PyDev 6.3.1. I'll make sure it's fixed in PyDev 6.3.2.

修剪字符串中括号内的任何子字符串(to trim a any substring inside bracket in the string)

尝试这个: import re line=r"X:\folder\Code\Mod\ACCSC1C1.c 351: Error -> Warning 550 Symbol XXX (line 34) not accessed" re.sub("\(line \d+\)", '', line) 'X:\ folder \ Code \ Mod \ ACCSC1C1.c 351:错误 - >警告550符号XXX未被访问' 从sub的文档: re.sub(pattern,repl,string,co

fullcalendar business.hours在非工作日的agendaDay视图中查看资源(fullcalendar businessHours on non-working days in agendaDay view with resources)

我的资源Ruby对象设置不正确。 只需检查businessHours是否已设置,如果没有,添加businessHours 只为每个资源设置了dow ,解决了我的问题。 resource_example = { id: my_id, title: my_title, businessHours: { dow: my_daynum } } My resource Ruby object was not set properly. Simply checking if businessHours i

一些基本的JavaScript的麻烦(trouble with some basic javascript)

你错过了new关键字: var tank1 = new tank(); You missed new keyword: var tank1 = new tank();

处理超过1024个插座?(Handling more than 1024 sockets?)

使用select对于这么多(数千)个连接来说是根本错误的。 虽然当你只有极少数的插座(可能是几十个)时, select通常会更快,但它可以扩展到几千个甚至更多。 在我知道的任何地方, select与连接数量线性减慢(它甚至比这更糟糕,但我不会详细介绍。) 即使poll也没有比select扩展到数千个连接更好。 它没有对可以轮询的文件描述符数量的select (低)限制,但它仍然与连接数线性地成比例。 您真正应该使用的是特定于平台的设施,如epoll和kqueue 。 它们的扩展性能非常好(通常为

c ++ - SendInput()无法正确管理Alt代码(c++ - SendInput() doesn't manage Alt codes properly)

使用扫描代码而不是虚拟键。 这会将密钥注入系统的低得多的水平,并比虚拟密钥更可靠地模拟真实的用户输入。 我花了一段时间才找到最终的扫描码列表,因为那里有一些差异。 但是,从本页中间的大表中引用“set 1”列似乎可行。 INPUT createScanCodeEvent(WORD scancode, bool isDown) { INPUT input = {}; input.type = INPUT_KEYBOARD; input.ki.wVk = 0; inp

为现有数据库创建初始迁移会导致空迁移(Creating initial migration for existing DB results in empty migration)

我的应用程序与Web API和MVC项目都是分层的。 因为我设置了多个启动项目,所以EF无法确定使用哪个应用程序来查找启动配置。 我正在将Add-Migrations应用于数据访问层,但连接字符串和实体框架初始化设置位于MVC web.config中。 将这些复制到数据访问层的App.Config后,所有工作都按预期工作。 My application is n-tiered with both a Web API and an MVC project. Because I have multi

相关文章

更多

最新问答

更多
  • 根据Woocommerce中的自定义字段计算自定义购物车商品价格(Custom cart item price calculation based on dimentions custom fields in Woocommerce)
  • 分开foreach项目并单独打印(Separate foreach items and print them individually)
  • 写模式管道是否同步?(Is write mode pipe synchronous?)
  • 发现可用的Windows Phone强调色和本地化名称(Discover available Windows Phone accent colors and localized names)
  • 使用多线程和WPF更新集合(Update Collection with multithreading and WPF)
  • 如何在字符串的情况下使用同步?(How should the synchronization be used in case of strings?)
  • 打印唯一的行,比较不超过N个字符(Print unique lines, compare no more than N characters)
  • Javascript / jQuery - 如何调用switch case从另一个函数执行(Javascript/jQuery - how to call a switch case to execute from another function)
  • Hbase超时错误不断发生(Hbase timeout errors keep occuring)
  • 如何在Delphi中更改TabControl中活动TAB的颜色(How to change the color of active TAB in a TabControl, in Delphi)
  • 正则表达式:在sublime文本中替换一些PHP代码(Regex: replace some pieces of php code in sublime text)
  • 在带有Scene2D的LibGDX中,如何在按下按钮时连续向右走?(In LibGDX with Scene2D, how can I continuously walk to the right when a button is pressed?)
  • 累加器如何在Haskell中工作?(How do accumulators work in Haskell?)
  • 使用开关检查市场和前缀与正确的货币符号(using switch to check market and prefix with correct currency symbol)
  • 在哪里分配一次使用类?(Where to allocate one time use class?)
  • 如何从两个DateTime / NaiveDateTime获取持续时间?(How do I get Duration from two DateTime / NaiveDateTime?)
  • 解析TimeSpan大于24小时?(Parse a TimeSpan greater than 24 hours? [duplicate])
  • 如何在球拍中本地更改阅读规则?(How to locally change reading rules in racket?)
  • 数据库应该由DI注入时的模拟存储(通过构造函数)(Mock storage when database should be injected by DI (through constructor))
  • 使用maven集成2个eclipse项目(Integrate 2 eclipse projects using maven)
  • 角度ng-repeat不检测变化(Angular ng-repeat not detecting changes)
  • Xaml组件在Silverlight + XNA应用程序的多个页面中可见(Xaml component visible in multiple pages in Silverlight+XNA applications)
  • 如何将`var`变量等同于另一个查询(How to equate `var` variable to another query)
  • 如何设计hyperledger链代码以适合您的业务?(how to design your chaincode of hyperledger to fit for your business?)
  • PHP readfile错误(PHP readfile error)
  • 在Date之后排序列表然后是时间(Sorting list after Date then time)
  • Android内部版本号(Android build number)
  • 在没有预设退出条件的情况下停止无限循环(stopping an infinite loop with no preset exit condition)
  • Phonegap应用程序全屏通过html页面中的按钮(Phonegap Application fullscreen through a button in html page)
  • PAA是否适合在门户网站中自动执行wcm库部署和设置?(Is PAA a good candidate for automating wcm library deployment and setup in portal?)