In this Blog i would like to share my Answers which i have posted on Code project.
Question: Can WatiN accept inputs from an Excel sheet
Can WatiN accept inputs form an excel sheet. this functionality was there in watir.
Is this available in WatiN.
Jawed: yes it is.for that you need to write simple C# code to read from excel sheet.see below
some example from my side.
public class CommonClassAutomation
static string connectionString
= “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=
D:/test.xls;Extended Properties=Excel 8.0;”;
public static string inputText= string.Empty;
public void TC_googletest()
//before calling instance of browser read input from excel sheet.
//Open instance of IE browser.
IE ie=new IE();
//Open Google.com in browser
/*Provide input text in to google search box. which you have already having from
//Click on Search button.
//Method To read data from Excel sheet
public void readExcelsheet()
DbProviderFactory factory = DbProviderFactories.GetFactory
using (DbConnection connection = factory.CreateConnection())
connection.ConnectionString = connectionString;
using (DbCommand command = connection.CreateCommand())
command.CommandText = “SELECT * FROM [“+ sheetName+“$]”;
using (DbDataReader dr = command.ExecuteReader())
Hope, it would be useful for you.
Hi I’m working on WatiN tool. I’ve scenario where i need to check a checkbox and click on ok button in the popup window. i’ve used AttachtoIE method and used URL attribute to attach to the popup window. Now the problem is URL contains the ID value, which changes each time the popup appears.. so how to handle this or is there any other method other than AttachtoIE.
please give some suggestion thanking you.
Other Member: Yes I got it right, I ignored the query string part in the URL which used to change everytime.
IE popup = IE.AttachToIE(Find.ByUrl(Url, true);
this worked for me, hope this will help you
Jawed: Hi,@ninay_fz: nice reply
Just I want to add few points over here to make your piece of code to work with dynamic changing URL.In this situation is good practice to use Regular expression.
Add this name space to your code file.
Use below code to generalize while accessing URL.
Regex reg = new Regex(Url);
IE popup = IE.AttachToIE(Find.ByUrl(reg , true));
Hope it would solve your problem.