//code hereI would like to use the PopupWatcher to always accept certificates presented in a browser. Though, I'll need to do it for IE, FF, and Chrome, I'm just trying to get Firefox working and then the other two. Another thing I should mention is that I come from Java land and have limited exposure to .Net.
All the popup watcher discussions seem to lead to one of two posts. Sorry for the abriviated link. This forum doesn't allow me to post URLs
1. Implemented in Program.cs
popupwatcher-in-ranorex-4-problem-with-repo-items-t4332.html
2. Implemented in a class which implements ITestModule
test-automation-code-examples.html#c4678
I wasn't able to get the thread to run in #2 (did not see inserted logging message appear in console), so I tried to get it working directly in Program.cs. I did see the log message like this, but doesn't provide any info about the problem:
Code: Select all
at Ranorex.Core.Repository.RepoItemInfo.Find[T](Boolean findSingle, Boolean throwException) at Ranorex.Core.Repository.RepoItemInfo.CreateAdapter[T](Boolean throwException) at Flex_vSphere_Client.SSLCertsRepoFolders.FFCertAppFolder.get_UnderstandRisk() in c:\source\ranorex\Flex-vSphere-Client\SSLCertsRepo.cs:line 183 at Flex_vSphere_Client.Program.AcceptCertFF(RxPath path, Element myElement) in c:\source\ranorex\Flex-vSphere-Client\Program.cs:line 61 at Ranorex.PopupWatcher.FindPopups(PopupItemCallback itemCallback, PopupPathCallback pathCallback, RxPath absPath, String itemName, RepoItemInfo optionalInfo)
Code: Select all
class Program
{
public static SSLCertsRepo repo = SSLCertsRepo.Instance;
[STAThread]
public static int Main(string[] args)
{
// Uncomment the following 2 lines if you want to automate Windows apps
// by starting the test executable directly
//if (Util.IsRestartRequiredForWinAppAccess)
// return Util.RestartWithUiAccess();
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
PopupWatcher sslCertWatcherFF = new PopupWatcher();
//sslCertWatcherFF.UpdateInterval = 5000;
Report.Log(ReportLevel.Info, "popup watcher trigger in Runner");
sslCertWatcherFF.Watch("/dom//button[@innertext='I Understand the Risks']", AcceptCertFF);
sslCertWatcherFF.Start();
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
return error;
}
public static void AcceptCertFF(Ranorex.Core.RxPath path, Ranorex.Core.Element myElement)
{
Report.Log(ReportLevel.Info, "popup watcher trigger");
//myElement.As<Ranorex.Button>().Click();
repo.FFCert.UnderstandRisk.Click();
repo.FFCert.ExceptionDialogButton.Click();
}
}
--Boris