Its pretty important. try the following, you will be able to do this !
public class WebDriverTestClass { public static void main(String a[]) throws InterruptedException { try { WebDriver driver = new FirefoxDriver(); // Go to Google Home Page26 driver.get("http://www.google.com"); // Look for search textbox and enter search term there WebElement searchBox = driver.findElement(By.name("q")); searchBox.sendKeys("WebDriver API"); // Click on 'Search'33 WebElement searchButton = driver.findElement(By.name("btnG")); searchButton.click(); // Not required or recommended any where, but just wait for the last37 // click() // operation to get completed fine Thread.sleep(2000); // to return the url System.out.println("What's the current Url: "+ driver.getCurrentUrl()); // if you wish to take screenshot of this page, File scrFile = ((TakesScreenshot) driver) .getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, new File( "c:\\screenshot\\googlesearch-webdriverapi.png")); // Close the driver, once you're done driver.close(); } catch (Exception e) {53 e.printStackTrace(); // For debugging purposes54 } } }
1 Comment
Hung Huynh
11/21/2011 03:10:22 pm
Understand a little. :)
Reply
Leave a Reply. |
AuthorI am Masud Parvez. Working as IT Senior Project Manager for RMIT University. Previously I built and run a distributed Test Center. My success was to turn that in to one of the most successful business units of the company. Categories
All
|