Copied link will be present in the clipboard, and once you've opened a new tab using this:
driver.SwitchTo().NewWindow(WindowType.Tab);
You could just do this:
driver.Navigate().GoToUrl(Clipboard.GetText());
if you are facing
The name 'Clipboard' does not exist in the current context
after that line of code, you would have to import:
using System.Windows.Forms;
This also could result in below fault:
The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?
for that you'll have to go inside your project directory and then go to the project file and add
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
this should solve the issue.
#Approach 2:
((IJavaScriptExecutor)driver).ExecuteScript("navigator.clipboard.readText().then(text => window.location.replace(text));");