Resolving – Element is not clickable at point

Here is a simple solution to resolve the Element is not clickable at point issue with ChromeDriver in Webdriver.
Here is the function I have written to detect the browser and then pause for .5 sec before executing the next command.

public bool CheckElementPresent(string Xpath)
{
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
string ibrowser = (string)js.ExecuteScript("return " + "navigator.userAgent");
if (ibrowser.Contains("Chrome"))
{
Thread.Sleep(500);
}
bool present = false;
for (int second = 0; ; second++)
{
if (second >= 10)
{
break;
}
if (IsElementPresent(Xpath))
{
present = true;
break;
}
Thread.Sleep(1000);
}
return present;
}

Here is the code where I have used the function:
//click view more link
CheckElementPresent(ViewmoreCategory_lnk);
Click(ViewmoreCategory_lnk);
//click add another keywords link
CheckElementPresent(AddAnotherHyperLink);
Click(AddAnotherHyperLink);

I hope this will be useful for you.

Getting the Browser details in Selenium

There are times when you would like to get the browser details when running the selenium scripts. Here is the selenium script that you can use to to get browser details.

String a = selenium.GetEval("navigator.appCodeName");
Console.WriteLine(a);
String b = selenium.GetEval("navigator.appName");
Console.WriteLine(b);
String c = selenium.GetEval("navigator.appVersion");
Console.WriteLine(c);
String d = selenium.GetEval("navigator.cookieEnabled");
Console.WriteLine(d);
String e = selenium.GetEval("navigator.platform");
Console.WriteLine(e);
String f = selenium.GetEval("navigator.userAgent");
Console.WriteLine(f);

The Results as under for the above code when the script is run of firefox version 3.5.7.
Mozilla
Netscape
5.0 (Windows; en-GB)
true
Win32
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7

How did this solution work for you? Do you have a better alternative? Feel free to share your thoughts in comments section below.

[ad#PostAD]