{"id":213,"date":"2011-09-23T20:43:57","date_gmt":"2011-09-23T19:43:57","guid":{"rendered":"http:\/\/www.michaelokarimia.com\/blog\/?p=213"},"modified":"2012-06-05T00:04:43","modified_gmt":"2012-06-04T23:04:43","slug":"allow-selenium-webdriver-c-tests-to-accept-javascript-popup-alerts","status":"publish","type":"post","link":"https:\/\/www.michaelokarimia.com\/blog\/2011\/09\/23\/allow-selenium-webdriver-c-tests-to-accept-javascript-popup-alerts\/","title":{"rendered":"Allow Selenium Webdriver C# tests to accept javascript popup alerts"},"content":{"rendered":"<p>\nI have been writing Selenium webdriver powered tests for over a year, as part of a suit of acceptance tests, and I was looking to prevent a test from failing when a JavaScript pop up alert interrupted the tests completion.\n<\/p>\n<p>\n<a href=\"http:\/\/qatechnotes.blogspot.com\/2011\/06\/testing-js-popup-box-using-selenium.html\" target=\"_blank\">I found the non C# solution blogged<\/a> but I&#8217;ve written the code in C# below:\n<\/p>\n<p><pre lang=\"csharp\" line=\"1\">\r\nWebDriver.SwitchTo().Alert().Accept();\r\n<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been writing Selenium webdriver powered tests for over a year, as part of a suit of acceptance tests, and I was looking to prevent a test from failing when a JavaScript pop up alert interrupted the tests completion. I found the non C# solution blogged but I&#8217;ve written the code in C# below: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[29,30],"class_list":["post-213","post","type-post","status-publish","format-standard","hentry","category-handy-tips","tag-selenium","tag-webdriver"],"_links":{"self":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":17,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions\/333"}],"wp:attachment":[{"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.michaelokarimia.com\/blog\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}