Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
717 views
in Technique[技术] by (71.8m points)

typescript - wildcard in playwright page.frame (url option)

I'm trying to find a way to use a wildcard in the page.frame(url) function of playwright, I have this code:

await page.frame({
    url: 'http://192.168.20.222:8080/ords/f?p=150:13:12188371642929::NO:13::&cs=3rW0d3IdG36wpBBz1GAnD2UV8kf7xWvgqUaa28l5eceRm71VjW6F33ufnHQnEvSAJpbB7CSDdVQNXeKOyLRYnQw&p_dialog_cs=IBgwSu6yIUBbITteHHI5ea8wU7JXa9CDY1LsEMKeBVEM7oYixeWw0HW9GrCAtCPffvG3VLlveff_t720koyh3Q'
}).click('button[id="B5602689567386780"]');

and when I open the same page with the test tool the url changes:

await page.frame({
    url: 'http://192.168.20.222:8080/ords/f?p=150:13:1511883080952::NO:13::&cs=3DJ0vt7NMVCCk4xQvKJoD-unSF5896wbfp99oGMQ0Qg7DaIbaeJOV0oqnEfkntXgnLNq902F97vpFAm2-dlFGRQ&p_dialog_cs=Ui4xj5jDt_J91vpSWo-MezLxSG60jFLoGhx3oh85DTIaR7Tv9c7wdCSXRRikra57RyQz2hvkPzZEXNqbwqF83g'
}).click('button[id="B5602689567386780"]');

Do I have any option to use a wildcard in the url?

Like * and have my code like this?

url: 'http://192.168.20.222:8080/ords/f?p=150:*'

question from:https://stackoverflow.com/questions/65906226/wildcard-in-playwright-page-frame-url-option

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could use a Regex for that:

(await page.frame({
    url: /http://192.168.20.222:8080/ords/f?p=150:.*/
})).click('button[id="B5602689567386780"]');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...