На моей веб-странице мы заполняем форму, там выбираем
Код: Выделить всё
UserNamethen clicking on apply button,
After that we are receiving alert pop up for like user is added.
I am adding Code to handle alert pop
Код: Выделить всё
Driver.SwitchTo().Alert().Accept();
error:-
Assert.Fail failed. OpenQA.Selenium.UnhandledAlertException:
unexpected alert open: {Alert text : Role added successfully.}
And My Test case is failing
(Session info: chrome=121.0.6167.86) at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse) at
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String
driverCommandToExecute, Dictionary`2 parameters) at
OpenQA.Selenium.Remote.RemoteWebDriver.GetScreenshot() at
UserManagement_Automation_Test_Suite.BaseClasses.ScreenShots.Take(String
fileName, String floderName) in
C:\UserManagement_Automation_Test_Suite\UserManagement_Automation_Test_Suite\BaseClasses\ScreenShots.cs:line
60 at
UserManagement_Automation_Test_Suite.TestCases.TS_User_Management_0012ManageUserRoles.Action_01()
in
C:\UserManagement_Automation_Test_Suite\UserManagement_Automation_Test_Suite\TestCases\TS_User_Management_0012ManageUserRoles.cs:line
30
-
Код: Выделить всё
Driver.SwitchTo().Alert().Accept();
Код: Выделить всё
public static void AlertPopUp()
{
string text = ObjectRepository.Driver.SwitchTo().Alert().Text;
Assert.IsTrue(text.Contains("User added successfully with email: pramod.kumar-ext@alstomgroup.com."));
}
Источник: https://stackoverflow.com/questions/781 ... irm-pop-up
Мобильная версия