I was creating a script in Java and wanted to run the script using TestNG and Eclipse. I was getting the following error when running the script.
The constructor DefaultSelenium(String, String, String, String) is undefined
To solve the issue you will have to make change to the setUp method.
My code was something like this selenium = new DefaultSelenium(“localhost”, “4444″, “*iexplore”, “http://www.google.com/”); having 4444 as a string. I then changed the code to selenium = new DefaultSelenium(“localhost”, 4444, “*iexplore”, “http://www.google.com/”);
Here is selenium function that you can use when you want to either click on a button or link. I have foud this code very useful and interesting.
public void clickElement(String object, String wait) {
String locator = getValue(object);
if (selenium.IsElementPresent(locator))
{
selenium.Click(locator);
Console.WriteLine("Clicked on " + object);
}
else
{
Console.WriteLine(object + " was not found");
}
waitForPageToLoad(wait);
}
You can write this function in a seperate functions class and then call this function in your test script class by referencing the functions class.
This is one my best finds so far and would like to share it with you. Here is an example that shows you how to use the xpath contains to build a xpath using part of the attribute value. This can be used when there are elements with the same id or text value.
Here is the way to disable add-ons window which appears every time when selenium scripts are run on Custom Firefox Profile.
Here is an alternative to using contains text() in xpath command
script type="text/javascript"
try {
var pageTracker = _gat._getTracker("UA-222222-3");
pageTracker._trackPageview();
} catch(err) {}script
Here is an example of how you can solve the issue relating to getting access to the share drive folder from your command prompt:
pushd \\Testing\Selenium_Tests\SeleniumSoftware\selenium-remote-control-1.0.1\selenium-server-1.0.1
The solution is to use pushd instead of cd to change the current directory to a share accessed via a UNC path