C# 打开 Microsoft Edge 并重用窗口

问题描述 投票:0回答:1
while (true)
{
    Console.WriteLine("Enter a URL");
    string strURL = Console.ReadLine();
    Process pWeb = new Process();
    pWeb.StartInfo.UseShellExecute = true;
    pWeb.StartInfo.FileName = "microsoft-edge:"+ strURL;
    pWeb.Start();
}

使用此代码,当您输入第一个 URL(例如 http://www.yahoo.com)时,它将打开 Edge to Yahoo,它会再次要求输入 URL,如果您输入不同的 URL( http://www.stackoverflow.com 为例)它将在 Edge 中打开第二个选项卡到 StackOverflow。

我想做的是让它覆盖已拉起的现有站点。我不希望它打开第二个选项卡,我希望它从 Yahoo 导航到 StackOverflow。

有什么办法可以做到这一点吗?

c# asp.net-core microsoft-edge
1个回答
0
投票
using OpenQA.Selenium.Edge;

Console.WriteLine("Enter a URL");
string strURL0 = Console.ReadLine();
var driver = new EdgeDriver();
driver.Url = "https://" + strURL0;

while (true)
{
    Console.WriteLine("Enter a URL");
    string strURL = Console.ReadLine();
    try
    {
        driver.Url = "https://" + strURL;
    }
    catch { }
}
© www.soinside.com 2019 - 2024. All rights reserved.