Search This Blog

August 15, 2016

Fixed the issue: HttpWebRequest.GetResponse() throws 500 error

Today one of our automated tests failed. After looking into this issue, I noticed that in this test case, we need to verify the http status code of some links.

The interesting part is that one external link is always working, but HttpWebRequest.GetResponse() always returned the error code 500.

After doing some research, I added the code (Yellow) in our utility class. After running the test again, the test passed.

string url="";
HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create(url);

myWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; 

WebResponse myWebResponse = myWebRequest.GetResponse();

August 11, 2016

How to handle multiple windows in Selenium?

If new members work on automated tests via our Selenium test framework, the common question they have is how to handle the additional window popbox if we click the url in the current window ?

It is pretty easy.  Using the following C # code works perfectly.

                      var windows = _driver.WindowHandles;

                      // do something such as Assertion.

August 10, 2016

Selenium: How to add C# code to Disable Developer mode extensions in Chrome ?

Today, one automated test failed in Chrome. My Chrome version is Chrome 52.0.2743.116.

 After looking into this issue, I noticed that when running the test in Chrome using C# and Selenium , “Disable Developer mode extensions” popbox appeared all the time. That explained why the test failed.

After adding the following code in the file and running the test, “Disable Developer mode extensions” popbox disappears all the time.

  Namespace: using OpenQA.Selenium.Chrome;
  ChromeOptions options = new ChromeOptions();
 _driver = new ChromeDriver(options);