[英]Using a Parameter for Method Using Browser.execute in JavaScript
This block of code works.这段代码有效。 I would like to parameterise the value passed to el.innText
.我想参数化传递给el.innText
的值。
selectTemplateCheckBox() {
const checkbox = this.templateCheckBox;
const temp = templateName;
browser.execute((selector) => {
selector.find(el => el.innerText === 'AG-1743RAJ').previousElementSibling.querySelector('input').click();
}, checkbox);
}
How can I parameterize the method for passing any value for AG1743RAJ
?如何参数AG1743RAJ
传递任何值的方法?
selectTemplateCheckBox(value) {
const checkbox = this.templateCheckBox;
const temp = templateName;
browser.execute((selector) => {
selector.find(el => el.innerText === value).previousElementSibling.querySelector('input').click();
}, checkbox);
}
This worked.这行得通。
selectTemplateCheckBox(templateName) {
const checkbox = this.templateCheckBox;
const temp = templateName;
browser.execute((selector, temp) => {
selector.find(el => el.innerText === `${temp}`).previousElementSibling.querySelector('input').click();
}, checkbox, temp);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.