【问题标题】:Protractor-nodejs : How to capture the dynamic text from the urlProtractor-nodejs:如何从 url 中捕获动态文本
【发布时间】:2021-10-10 05:17:00
【问题描述】:
我想使用量角器节点 js 从以下 URL 捕获“PR001-CC001234”。我知道如何获取当前 url 并将其存储在变量中。但是在捕获 url 末尾的动态文本时需要帮助。
http://example.com/cont/abc/PR123/region/Locale/01/PR001-CC01234.html?path=/cont/abc/PR123/region/locale/01/PR001-CC01234
【问题讨论】:
标签:
javascript
node.js
selenium
protractor
【解决方案1】:
你可以这样做
const url =
"http://example.com/cont/abc/PR123/region/Locale/01/PR001-CC01234.html?path=/cont/abc/PR123/region/locale/01/PR001-CC01234";
const parts = url.split("/");
console.log(parts[parts.length - 1]);
//PR001-CC01234