Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium JavaScript在下拉菜单中单击_Javascript_Selenium_Google Chrome_Browser_Automation - Fatal编程技术网

Selenium JavaScript在下拉菜单中单击

Selenium JavaScript在下拉菜单中单击,javascript,selenium,google-chrome,browser,automation,Javascript,Selenium,Google Chrome,Browser,Automation,下面的代码转到一个页面,找到下拉菜单并单击列表中的第一个。如何调整以下代码以选择列表中的第二项或第三项 await browser .findElement(By.css('#historyTabDropdown ul>li>a')) .then(e => e.click()); 尝试使用css选择器第n个子项。 css是第n个孩子(2) await browser .findElement(By.css('#historyTabDr

下面的代码转到一个页面,找到下拉菜单并单击列表中的第一个。如何调整以下代码以选择列表中的第二项或第三项

await browser
       .findElement(By.css('#historyTabDropdown ul>li>a'))
       .then(e => e.click());

尝试使用css选择器第n个子项。 css是第n个孩子(2)

await browser
       .findElement(By.css('#historyTabDropdown ul>li:nth-child(2)>a'))
       .then(e => e.click());