Как я могу перейти к всплывающему окну, используя переключатель в команду - PullRequest
0 голосов
/ 27 мая 2019

Я пытаюсь перейти к всплывающему окну с помощью коммутатора, но не могу переместиться.

Код всплывающего окна выглядит так:

!DOCTYPE html><html>

<head><title>Memo Display/Update on Action (OFACREVIEW): OFACREVIEW</title>

<link rel='stylesheet' href='css/standard.css'>

<link rel='stylesheet' href='css/eWireCommon.css'>

<script>

</script>

</head>

<body onload='document.getElementsByName("reas_memo_out")[0].focus();document.getElementsByName("reas_memo_out")[0].select();'>

<FORM NAME='memoform'><H2 class='pageTitle inlineTitle' style='padding-left:54px;'>Memo</H2><center>

<table align='center' class='table1' style='border-style: solid; border-width: 1px; border-color: #bbbbbb; margin-bottom:5px; '>

<tr><td><textarea name='reas_memo_in' rows='7' cols='70' readonly='readonly'

style='background: #FFFFFF; color: #222222; overflow:auto; border-style: solid; border-width: 0px;border-bottom-width: 1px;'>TRANSACTION ORIGINALLY IN OFVPAYQ(17-OCT-2018 8:20:35/SYSTEM)</textarea>

</td></tr>

<tr style='background: #FFFFFF'><td>

<textarea name='reas_memo_fixed' rows='2' cols='70'

readonly='readonly'

style='color: red; overflow:auto; border-color: #bbbbbb; border-style: solid; border-width: 0px;border-bottom-width: 1px;'>Sent for OFAC Review</textarea>

</td></tr>

<tr style='background: #FFFFFF'><td>

<textarea name='reas_memo_out' rows='7' cols='70' tabindex='1'

style='color: #222222; overflow:auto; border-color: #bbbbbb; border-style: solid; border-width: 0px;'

onkeyup='javascript:textareaCounter (reas_memo_out, 920);'></textarea>

</td></tr>

</table>

<div>

<button TYPE='button' class='save_button button secondary2' Name='close_memo'

Value='' title='Save Memo/Close Window' onclick='javascript:goBackToWindowOpener("OFACREVIEW",1);'>

<span class='buttonLabel'>Save</span>

</button>

<button TYPE='button' class='clear_button button secondary2 onlyLabel' Value='' Name='clear_memo'

onclick='javascript:clearMemo();'>

<span class='buttonLabel'>Clear</span>

</button>

<button type='button' class='close_button button secondary2' name='close_memo'

Value='' title='Close Window' onclick='window.close()'></button>

</div>

</center></FORM></body></html>

Selenium C # код, который у меня естьнаписано для переключения окна как:

string OFACReviewpopup = AppBaseFL.isPopupPresent2();

if (OFACReviewpopup != null)

{

SetUpClass.myBrowser.switchToWindow(OFACReviewpopup);

myBrowser.Driver.FindElement(By.XPath("//form[@name='memo']"));

OFACObj.TxtOFACRevAreaMemo.SetValue("Sending the outgoing wire for OFAC Review");

AppBaseFL.WaitForTime(500);

myBrowser.Driver.FindElement(By.XPath("//input[@title='Save Memo/Close Window']")).Click();

AppBaseFL.WaitForTime(1000);

IAlert SentForOFACReview = AppBaseFL.isAlertPresent();

if (SentForOFACReview != null)

{

if (SentForOFACReview.Text.Contains("Send this payment for OFAC Review ?\r\nPress OK to Confirm."))

{

SentForOFACReview.Accept();

}

else

Assert.Ignore("Incorrect Alert, not able to release the payment to OFAC Review queue");

}

//SetUpClass.myBrowser.Driver.SwitchTo().Window(OFACReviewpopup).Close();

}

else

Assert.Ignore("Memo popup window not found, not able to release the payment to OFAC Review queue");

AppBaseFL.WaitForTime(1000);



public static string isPopupPresent2()

{

string popupWindowHandle = null;

try

{

WebDriverWait wait = new WebDriverWait(SetUpClass.myBrowser.Driver, TimeSpan.FromSeconds(10));

popupWindowHandle = wait.Until<string>((d) =>

{

string popupHandle = null;

if (SetUpClass.myBrowser.WindowHandles.Count > 0)

{

foreach (string handle in SetUpClass.myBrowser.WindowHandles)

{

if (handle != SetUpClass.GFTHomePageHandle)

{

popupHandle = handle;

break;

}

}

}

return popupHandle;

});

}

catch (NoSuchWindowException)

{

return null;

}

return popupWindowHandle;

}

Но я получаю результат как:

OpenQA.Selenium.WebDriverException: 'HTTP-запрос к удаленному серверу WebDriver для URLhttp://localhost:54696/session/7318662c-f715-4bfd-8864-f56be901b521/window истекло время ожидания через 60 секунд. '

Внутренняя веб-исключительная ситуация:

WebException: запрос был прерван: операция завершилась по тайм-ауту.

...