[英]How to click a link and open it in a new tab Selenium WebDriver C#
[英]Selenium + C# How to switch another Tab of Firefox when click a link and it will open in another tab?
我在C#中使用SeleniumRC,單擊鏈接時如何切換Firefox的另一個選項卡,它將在另一個選項卡中打開? 請有人幫我解決這個功能。 目標很簡單,即移動另一個打開的選項卡以搜索一些文本。
這段代碼在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);
}
}
有關使用WebDriver打開新選項卡的類似問題,請參閱此解決方案。 https://stackoverflow.com/a/9122450/648076
似乎不支持立即使用,但是您可以執行試圖為您打開新標簽頁的javascript。
您可以使用selenium.SelectWindow
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.