Javascript 带中频圆锥曲线量角器的异步for循环 var createTime=10:00; var createdPatient=“vijay”; /*将时间与createdTime比较后的In-for循环“i”值应为比较索引,但“i”值每次都将成为最后一个索引*/ 元素(by.xpath(“//div[@id='patients']))。全部(by.xpath(“div[@class='ng-scope'])),然后( 函数(divtags){ 对于(i=0;i

Javascript 带中频圆锥曲线量角器的异步for循环 var createTime=10:00; var createdPatient=“vijay”; /*将时间与createdTime比较后的In-for循环“i”值应为比较索引,但“i”值每次都将成为最后一个索引*/ 元素(by.xpath(“//div[@id='patients']))。全部(by.xpath(“div[@class='ng-scope'])),然后( 函数(divtags){ 对于(i=0;i,javascript,testing,protractor,end-to-end,Javascript,Testing,Protractor,End To End,否),这不是在量角器中解决此类问题的方法。您需要一个过滤器,以按时间和姓名筛选所需的“患者” 下面是代码和一些额外的改进: var createTime=10:00; var createdPatient="vijay"; /* In for loop after comparing the time with createdTime 'i' value should be the compare index but 'i' value becoming last ind

否),这不是在量角器中解决此类问题的方法。您需要一个过滤器,以按时间和姓名筛选所需的“患者”

下面是代码和一些额外的改进:

    var createTime=10:00;
    var createdPatient="vijay";
    /* In for loop after comparing the time with createdTime 'i' value should be the compare index but 'i' value becoming last index each time*/ 
    element(by.xpath("//div[@id='patients']")).all(by.xpath("div[@class='ng-scope']")).then(
function(divtags){
for(i=0;i<divtags.length;i++){
divtags[i].element(by.xpath("div[1]/div[2]")).getText().then(function(time){
if(time==createdTime){
 /*Here i am getting 'i' value every time last divtag length */        divtags[i].element(by.xpath("div[@class='patient']")).getText().then(function(patientName){
if(patientName==createdPatient){
divtags[i].click();
}})}});}});

我不能保证它能按原样工作,因为我没有办法复制和测试它,但我希望你能得到这个想法,并能适当地调整建议的解决方案。

不,这不是你在量角器中解决类似问题的方法。你需要一个过滤器,按时间和名称过滤所需的“患者”

下面是代码和一些额外的改进:

    var createTime=10:00;
    var createdPatient="vijay";
    /* In for loop after comparing the time with createdTime 'i' value should be the compare index but 'i' value becoming last index each time*/ 
    element(by.xpath("//div[@id='patients']")).all(by.xpath("div[@class='ng-scope']")).then(
function(divtags){
for(i=0;i<divtags.length;i++){
divtags[i].element(by.xpath("div[1]/div[2]")).getText().then(function(time){
if(time==createdTime){
 /*Here i am getting 'i' value every time last divtag length */        divtags[i].element(by.xpath("div[@class='patient']")).getText().then(function(patientName){
if(patientName==createdPatient){
divtags[i].click();
}})}});}});
我不能保证它能按原样工作,因为我没有办法复制和测试它,但我希望你能得到这个想法,并能适当调整提议的解决方案