Using a.click(); is invalid. It is obviously OK at other times.
而且就算那我获取了href 在用js打开也没反应 这是为什么呢
((JavascriptExecutor)driver).executeScript("window.open('"+href+"')");
((JavascriptExecutor)driver).executeScript("alert('"+href+"')");
alert能弹出
But window.open() does not respond. It works if I type it directly on the console on the web page
window.open() opens a new tab, you need to switch handles. Here are two methods for your reference:
As for the click, it may be because the element is not explicitly visible, or needs to be focused, or you are using Selenium improperly, but it is recommended to try js click