Image Verification

Webdriver and Image Verification

Can you do image verification if it loaded on webpage?

 Yes! You can verify but you cannot say that images are half loaded. To verify if an image is correct then there would be some other method but the code will tell you just that images are loaded on the page or not.

You can send HTTP request to that source using GET method and check the status code as 200. if that the case then your image downloaded properly and an image is there. 

Please drop your comments if you think if I am missing anything. If you have another idea to do image verification, please comment.

JavaScript Alerts and Selenium/Webdriver.

One of the most popular question among selenium/Webdriver users. I used that couple of places to handle.

Selenium RC: if you are expecting javaScript alert and  you want to handle using OK then use following commands and then you can use your code.

selenium.chooseCancelOnNextConfirmation()
selenium.chooseOkOnNextConfirmation()

Note: In Firefox 4.0 and higher version, you will see alerts like following and its impossible to handle this via selenium.

There is a workaround to handle this.

Type ‘about:config’ in Address bar of firefox browser and accept the warning.

Type “tab_”. You will see prompts.tab_model.enabled option with Value: true.

Double click on the row which will make it false.

Now alert will look like:

 

Webdriver:

There is command to handle alert are:

driver.SwitchTo().Alert().Accept();
driver.SwitchTo().Alert().Dismiss();
driver.SwitchTo().Window(“windowName”);

You can handle as per your need.

 

Selenium Core & Customized Keywords

[grpdocsview file=”” height=”700″ width=”600″]We have completed basics of Selenium IDE so far. Today we will talk more about keywords/commands. However we will not go in very detail because you can find all those commands on selenium’s own website. I will try to explain some frequently used commands only. While doing recording in Selenium IDE you noticed many keywords like clickAndWait etc. These keywords are actually customized with help of core keywords like click() and wait(). IDE creator wanted to give enough capability to testers to use standalone IDE for testing so these keywords are included there.

How to understand customized methods

If you see on this screenshot, you can see the explanation of every keyword in Reference tab.Screen shows clickAndWait (locator) keyword which is being derived from Click (locator) and WaitForPageToLoad (timeout).If IDE sense any page/frame load after the click, its sends clickAndWait() command else only click().

 

Today we will try to understand these IDE keywords and core keywords as well. I will show you comparison between these two types of keywords. Don’t try to go in detail about selenium keywords for now. I will explain you these keywords in next section.