如何使用节点Puppeteer设置select的值(How to set value of select with node Puppeteer)

参考:https://www.it1352.com/1955345.html

参考官方文档:https://zhaoqize.github.io/puppeteer-api-zh_CN/#?product=Puppeteer&version=v5.5.0&show=api-pageselectselector-values

page.select('select#example','carrot'); 

这里注意了:使用JavaScript原生的select赋值方法在puppeteer不行【自行测试】

基于原生js是可以的,但是puppeteer框架则无法这里赋值select选择器!【请使用官方的page.select('select#example','carrot'); 】

<select class="io">
	<option value="1111">sms</option>
	<option value="2111">google</option>
</select>
<script>

	let ele = document.getElementsByTagName('select')[0];

	console.log(ele.value)
</script>

猜你喜欢

转载自blog.csdn.net/weixin_43343144/article/details/112288697