简体   繁体   English

Selenium + C#单击链接时如何切换Firefox的另一个选项卡,它将在另一个选项卡中打开?

[英]Selenium + C# How to switch another Tab of Firefox when click a link and it will open in another tab?

I'm using SeleniumRC with C#, How to switch another Tab of Firefox when click a link and it will open in another tab? 我在C#中使用SeleniumRC,单击链接时如何切换Firefox的另一个选项卡,它将在另一个选项卡中打开? Some one please help me out, in this functionality. 请有人帮我解决这个功能。 The goal is simple to move another opened tab to search some text. 目标很简单,即移动另一个打开的选项卡以搜索一些文本。

This code is in C# 这段代码在C#中

public void TheUntitledTest()
{
    selenium.Open("/abc/static/index.html");
    // selenium.WindowFocus();
    selenium.Click("link=Privacy Statement");
    selenium.WaitForPopUp("hello world - Mozilla Firefox", "20000");
    selenium.SelectPopUp("hello world - Mozilla Firefox");
    selenium.WaitForPageToLoad("30000");
    for (int second = 0; ; second++)
    {
        if (second >= 60) Assert.Fail("timeout");
        try
        {
            if (selenium.IsTextPresent("welcome")) break;
        }
        catch (Exception)
        {
        }
    Thread.Sleep(1000);
    }
}

See this solution for similar question of opening a new tab with WebDriver. 有关使用WebDriver打开新选项卡的类似问题,请参阅此解决方案。 https://stackoverflow.com/a/9122450/648076 https://stackoverflow.com/a/9122450/648076

It seems it is not supported out of the box but you can execute javascript that tries to open new tab for you. 似乎不支持立即使用,但是您可以执行试图为您打开新标签页的javascript。

您可以使用selenium.SelectWindow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何单击链接并在新选项卡中打开它 Selenium WebDriver C# - How to click a link and open it in a new tab Selenium WebDriver C# 在新标签页硒C#中打开链接 - Open link in new tab selenium c# C#Selenium firefox打开新选项卡不起作用 - c# selenium firefox open new tab is not working 如何在ASP C#上打开新标签页,然后将焦点集中在当前页面上,然后单击按钮将当前页面重定向到另一个页面? - How to open new tab on ASP C# and focus stay on current page then current page redirect to another page on click button? Selenium:使用C#在RemoteWebDriver中切换选项卡 - Selenium: switch tab in RemoteWebDriver with C# 如何使用 Safari 浏览器的 selenium C# 切换到新选项卡 - How to switch to new tab using selenium C# for Safari Browser 如何在新选项卡中打开链接Selenium UI自动化测试C# - How to open the link in new tab Selenium UI automation test C# c# 如何在 selenium 4.4.3 中找到为用户打开的选项卡 - c# how to find which tab is open for user in selenium 4.4.3 如何从一个选项卡切换到另一个选项卡Xamarin IOS - how to switch from one tab to another tab Xamarin IOS Selenium C#-如何单击基于同一行中另一个单元格的单元格中的链接? - Selenium C# - How to click on a link in a cell based on another cell in the same row?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM