Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97762

Manifest a click into another tab instead of the current (default) one in Selenium

$
0
0

Let's say there is an element with xpath "//a[@href]" that doesn't have a direct link to it and when clicked opens the UNKNOWN url in the current tab. Is there a way to make it open the URL in another tab instead of current one, so basically to "divert" the click into an another tab.

Here is some clarification:

driver.execute_script("arguments[0].click();", element) # clicks on an element
driver.execute_script("window.open()")

First line will click an element, and second would open a new tab, but as it is these lines aren't connected. Is there a way to execute just one script that would perform the click AND redirect it to be opened in a new tab?


Viewing all articles
Browse latest Browse all 97762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>