Use of AutoIt with selenium webdriver Is very useful because selenium webdriver Is not able to handle windows dialog like file upload dialog, file download dialog, HTTP proxy authentication dialog etc. But AutoIt Is desktop application testing tool and It Is very stable with handling all these kind of dialog. Let's try to work with HTTP proxy authentication dialog.

Downloading file using selenium webdriver Is also tricky task. I have already described how to handle file download functionality In selenium webdriver by creating custom firefox profile In THIS POST. It Is really very long task. At place of using custom profile approach, We can use AutoIt script with selenium webdriver to download file from any web page.

As you know, File uploading Is very hard In selenium webdriver because It Is not able to handle file uploading dialog. So we will use AutoIT with selenium webdriver to upload file In web applications. We have already created AutoIt script (Script To Upload File.exe) In previous post which can select file from File Upload dialog. We will learn how to Integrate that AutoIt script with selenium webdriver In this section.

Before creating and running file upload script In AutoIT, You must be aware about what Is AutoIT and how to Install It. I have already described about AutoIT In THIS POST and how to download and Install It In THIS POST. Now let us learn how to create script In AutoIT to upload file using selenium webdriver.

As I described In PREVIOUS POST, Auto IT Is opensource automation tool and can help us to handle windows element In our selenium webdriver test cases. We need AutoIT and AutoIT script editor to write test scripts.

Steps To Download AutoIT

As you know, It Is very hard to automate windows popup dialog box like file upload dialog, file download and save dialog, windows authentication dialog etc In selenium webdriver because It Is designed to automate web applications. Surly there are few work around to do all these things In selenium webdriver but do not have any strong and stable feature using which we can do all these things easily. In this section, We will learn something about Auto IT automation and Its usage with webdriver.

Part 19

88 : In XPath, I wants to do partial match on attribute value from beginning. Tell me two functions using which I can do It.

Answer : We can use bellow given two functions with XPath to find element for software web page using attribute value from beginning.
  1. contains()
  2. starts-with()

Sometimes you need to read font properties like font size, font color, font family, font background color etc.. during WebDriver test case execution. Selenium WebDriver Is very wast API and It has many built In methods to perform very small small operations on web page. Reading font property manually Is very simple task using firebug as shown In bellow given Image.

Part 18

83 : What are the benefits of parallelism over normal execution?

Answer : Using parallelism facility of TestNG In selenium webdriver,
  • Your software test execution time will be reduced as multiple tests will be executed simultaneously.
  • Using parallelism, We can verify multithreaded code In software application.

expectedExceptions Is very good feature of testng using which we can Ignore known but not required exceptions. In your selenium webdriver test execution, You can use expectedExceptions when you know that any specific @Test method can throw specific exception but It Is not much more Important and you wants to Ignore that exception.

Part 17

78 : What Is the syntax to get value from text box and store It In variable.

Answer : Most of the time, String In text box will be stored as value. So we need to access value attribute(getAttribute) of that text box as shown In bellow example.

String Result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value");

Grouping tests Is another very good feature of testng using which you can create group of test methods. You can create a group of test methods based on functionality and features, or based on modules or based on testing types like functional testing, sanity testing etc.. This way you can differentiate specific group test methods from all test methods.

Part 16

73 : How to set priority of @Test method? What Is Its usage?

Answer : In your software web application's test case, you can set priority for TestNG @Test annotated methods as bellow.
@Test(priority=0)

Using priority, We can control @Test method execution manner as per our requirement. That means @Test method with priority = 0 will be executed 1st and @Test method with priority = 1 will be executed 2nd and so on. VIEW PRACTICAL EXAMPLE to know how to use It.

Sometimes you will have a case where few of the @Test methods are taking very very long time to complete the execution or get stuck due to the some reason. In this case, Supposing you wants to mark such @Test methods as failed and go for executing next @Test method. TestNG has very good feature using which you can set time period to wait for a test to completely execute.