Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 将标题文本与量角器中的数组进行比较_Arrays_Protractor - Fatal编程技术网

Arrays 将标题文本与量角器中的数组进行比较

Arrays 将标题文本与量角器中的数组进行比较,arrays,protractor,Arrays,Protractor,我在md表中有大约11列。我可以比较10个标题标签,但其中一个标签中有换行符。我不知道如何比较那一个 <th md-column="" class="md-column ng-isolate-scope"><span>Accessorial<br>(Agent Fee / Customer Charge)</span></th> 附加费(代理费/客户费) 这是换行符标题标签的html。有人能帮我比较一下这个列标签吗 我的代码如下 c

我在md表中有大约11列。我可以比较10个标题标签,但其中一个标签中有换行符。我不知道如何比较那一个

<th md-column="" class="md-column ng-isolate-scope"><span>Accessorial<br>(Agent Fee / Customer Charge)</span></th>
附加费
(代理费/客户费)
这是换行符标题标签的html。有人能帮我比较一下这个列标签吗

我的代码如下

colheadernames = ['a','b','c'];
       cnt = element.all(by.css('.md-column')).then(function(arr){
        for ( i = 0; i < arr.length; i++) {
            arr[i].getText().then(function(text) {
                items.push(text.trim());
            });
        }


  }).then(function(){
        expect(items).toEqual(colheadernames);
    });
colheadernames=['a','b','c'];
cnt=element.all(by.css('.md column'))。然后(function(arr){
对于(i=0;i
谢谢,
mallesh

可以使用array.map()来解决问题,而不是遍历每一列,请看下面的示例

var colheadernames = ['a','b','c'];
var colheaderFrombrowser =element.all(by.css('.md-column')).getText().then(function(arr){
    return arr.map(function(arrayValue){
           return arrayValue.replace(/\n/g, " ");  //will replace all line breaks with " "
      })
})

expect(colheadernames).toEqual(colheaderFrombrowser)

尝试使用此text=text.replace(/\n/g,“”)//它将用“”items.push(text.trim())替换新行;嗨,苏达桑,谢谢你的回答。但我得到了这个错误。预期['Segment Ref#'、'Agent'、'Customer'、'收货人'、'附加费(代理费/客户费)']等于ManagedPromise::309{[[PromiseStatus]]:“pending”}。嘿,我使用了相同的代码并使用了您的替换。它现在正在为我工作。您知道使用哪个函数连接字符串吗。我正在使用concat,但我收到一个错误消息,说-concat未定义。