await browser.executeScript("document.querySelector(\"body > moo-shell > auto-app\").shadowRoot.querySelector(\"section > auto-farms\").shadowRoot.querySelector(\"section:nth-child(2) > auto-farm\").shadowRoot.querySelector(\"section:nth-child(2) > auto-barn\").shadowRoot.querySelector(\"div > section:nth-child(1) > vaadin-text-field\").shadowRoot.querySelector(\"div > div:nth-child(2) > slot:nth-child(2) > input\").value = \"\";").then(function () {
browser.executeScript("document.querySelector('body > moo-shell > auto-app').shadowRoot.querySelector('section > auto-farms').shadowRoot.querySelector('section:nth-child(2) > auto-farm').shadowRoot.querySelector('section:nth-child(2) > auto-barn').shadowRoot.querySelector('div > section:nth-child(1) > vaadin-text-field').shadowRoot.querySelector('div > div:nth-child(2) > slot:nth-child(2) > input').value = 'Automated Test Barn';");
})
await browser.sleep(5000);
await browser.executeScript("document.querySelector(\"body > moo-shell > auto-app\").shadowRoot.querySelector(\"section > auto-farms\").shadowRoot.querySelector(\"section:nth-child(2) > auto-farm\").shadowRoot.querySelector(\"section:nth-child(2) > auto-barn\").shadowRoot.querySelector(\"div > section.tanks > auto-tanks-field\").shadowRoot.querySelector(\"div.row-wrapper > div.row > vaadin-text-field\").shadowRoot.querySelector(\"div > div:nth-child(2) > slot:nth-child(2) > input\").click();").then(function () {
console.log("Tanks text box is clicked");
})
设定值
let setValue = function ($element, value){
return browser.executeScript(
`arguments[0].value = ${value};`,
$element.getWebElement()
)
}
即使不可见也单击元素
let jsClick = function ($element){
return browser.executeScript(
"arguments[0].click();",
$element.getWebElement()
)
}