Professional Documents
Culture Documents
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
WebDriver driver;
Logger logger;
@BeforeTest
public void launch() {
logger =Logger.getLogger("GoogleSearch");
PropertyConfigurator.configure("Log4j.properties");
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,"/
projects/challenge/phantomjs-2.1.1-linux-x86_64/bin/phantomjs");
driver = new PhantomJSDriver(caps);
logger.info("PhantomJS Headless Driver launched");
// Write the Parameter tag and drive the values from testng.xml file and pass the
value inside the methods
@Test
@Parameters({"URL","searchKey"})
public void googleSearch (String URL,String searchKey) throws
InterruptedException {
driver.get(URL);
Thread.sleep(5000);
logger.info("URL have been hitted");
<!-- Create Parameter tag and link the class file here -->
<parameter name="URL" value="https://google.com" />
<parameter name="searchKey" value="Fresco Play" />
<test name="testGuru">
<classes>
<class name="googleSearch.GoogleSearch">
</class>
</classes>
</test>
</suite>