<tfoot id='urimC'></tfoot>

      <bdo id='urimC'></bdo><ul id='urimC'></ul>

      1. <small id='urimC'></small><noframes id='urimC'>

        <i id='urimC'><tr id='urimC'><dt id='urimC'><q id='urimC'><span id='urimC'><b id='urimC'><form id='urimC'><ins id='urimC'></ins><ul id='urimC'></ul><sub id='urimC'></sub></form><legend id='urimC'></legend><bdo id='urimC'><pre id='urimC'><center id='urimC'></center></pre></bdo></b><th id='urimC'></th></span></q></dt></tr></i><div id='urimC'><tfoot id='urimC'></tfoot><dl id='urimC'><fieldset id='urimC'></fieldset></dl></div>
      2. <legend id='urimC'><style id='urimC'><dir id='urimC'><q id='urimC'></q></dir></style></legend>

        使用 Selenium 在现有浏览器会话中打开一个新选项卡

        时间:2023-09-14
            <tbody id='KRC6w'></tbody>

            <legend id='KRC6w'><style id='KRC6w'><dir id='KRC6w'><q id='KRC6w'></q></dir></style></legend>

          1. <i id='KRC6w'><tr id='KRC6w'><dt id='KRC6w'><q id='KRC6w'><span id='KRC6w'><b id='KRC6w'><form id='KRC6w'><ins id='KRC6w'></ins><ul id='KRC6w'></ul><sub id='KRC6w'></sub></form><legend id='KRC6w'></legend><bdo id='KRC6w'><pre id='KRC6w'><center id='KRC6w'></center></pre></bdo></b><th id='KRC6w'></th></span></q></dt></tr></i><div id='KRC6w'><tfoot id='KRC6w'></tfoot><dl id='KRC6w'><fieldset id='KRC6w'></fieldset></dl></div>
              <tfoot id='KRC6w'></tfoot>
                <bdo id='KRC6w'></bdo><ul id='KRC6w'></ul>

                  <small id='KRC6w'></small><noframes id='KRC6w'>

                1. 本文介绍了使用 Selenium 在现有浏览器会话中打开一个新选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我当前在 C# 中的代码打开一个窗口,然后在单击按钮后导航到指定的 URL.

                  My current code below in C# opens a window then navigates to the specified URL after a button click.

                  protected void onboardButton_Click(object sender, EventArgs e)
                  {
                     IWebDriver driver = new ChromeDriver();
                     driver.FindElement(By.CssSelector("body")).SendKeys(Keys.Control + "t");
                     driver.Navigate().GoToUrl("http://www.google.com")
                  }
                  

                  但我计划导航到的站点具有单点登录.如何在我的现有浏览器会话中打开一个新标签页并从那里导航?上面的代码好像不行.

                  But the site that I am planning to navigate to has single sign-on. How can I open a new tab in my existing browser session and navigate from there? The above code does not seem to work.

                  推荐答案

                  要处理新标签,您应该先切换到它.请尝试以下操作:

                  To handle new tab you should switch to it first. Try following:

                  driver.FindElement(By.CssSelector("body")).SendKeys(Keys.Control + "t");
                  driver.SwitchTo().Window(driver.WindowHandles.Last());
                  driver.Navigate().GoToUrl("http://www.google.com")
                  

                  您可能还需要切换回来:

                  Also you might need to switch back:

                  driver.SwitchTo().Window(driver.WindowHandles.First());
                  

                  这篇关于使用 Selenium 在现有浏览器会话中打开一个新选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:无法在 Selenium C# 中获取 Chrome 性能日志 下一篇:如何通过 Selenium、ChromeDriver 和 GoogleChrome 打开默认 Chrome 配置文件

                  相关文章

                    <small id='XacyK'></small><noframes id='XacyK'>

                  1. <i id='XacyK'><tr id='XacyK'><dt id='XacyK'><q id='XacyK'><span id='XacyK'><b id='XacyK'><form id='XacyK'><ins id='XacyK'></ins><ul id='XacyK'></ul><sub id='XacyK'></sub></form><legend id='XacyK'></legend><bdo id='XacyK'><pre id='XacyK'><center id='XacyK'></center></pre></bdo></b><th id='XacyK'></th></span></q></dt></tr></i><div id='XacyK'><tfoot id='XacyK'></tfoot><dl id='XacyK'><fieldset id='XacyK'></fieldset></dl></div>
                    <legend id='XacyK'><style id='XacyK'><dir id='XacyK'><q id='XacyK'></q></dir></style></legend>
                  2. <tfoot id='XacyK'></tfoot>

                      • <bdo id='XacyK'></bdo><ul id='XacyK'></ul>