element(by.css('.panel-body')).getText();<-return object Objct
element(by.className('panel-body')).getText();<-return object Object
element(by.id('message-body')).getText();<-return object Object
element(by.xpath('//*[@id="message-body"]/text()[3]')).getText()<-return textObject
有
HTML视图,我需要将此链接0.0.0.0:3000转换为字符串,你能帮助我吗?感谢:)
答案 0 :(得分:1)
使用正则表达式提取URL:
element(by.css('#message-body'))
.getText()
.then(text => text.match(/[^"\s]+\/student\/register\/\?[^"\s]+/)[0])
.then(url => console.log(url));