解决办法:

需要在.value赋值后,手动触发input事件

dom元素.value = “admin”
dom元素.dispatchEvent(new Event(‘input’))

例:fast os docker的登录页

let name = document.querySelector(
	"#app > section > section > main > div.main.clearfix > div > div > div > p:nth-child(3) > input[type=text]"
)
let pass = document.querySelector(
	"#app > section > section > main > div.main.clearfix > div > div > div > p:nth-child(5) > input[type=password]"
)
let login = document.querySelector(
	"#app > section > section > main > div.main.clearfix > div > div > div > p.submit > button"
)

if(name && pass){
	name.value = "admin"
	name.dispatchEvent(new Event('input'))
	pass.value = "888888"
	pass.dispatchEvent(new Event('input'))
	login.click()
}

版权声明:本文为CSDN博主「混乱谜零」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u013595395/article/details/109730815

Logo

前往低代码交流专区

更多推荐