static WebDriver driver = new FirefoxDriver();
public static void main(String[] args) throws IOException, InterruptedException {
// TODO code application logic here
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter base url....!!!");
String baseurl = br.readLine();
connection c= new connection();
c.makeConnection(driver,baseurl);
JavascriptExecutor js;
if (driver instanceof JavascriptExecutor) {
js = (JavascriptExecutor)driver;
js.executeScript("alert('hello world');");
}
Following error occurs
Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present: hello world
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:11:15'
System info: host: 'comp74', ip: '192.168.0.74', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_17'
Session ID: f6ba3a2b-87d4-4192-ad1a-94cf260d8f6e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:174)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:332)
at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:408)
at org.openqa.selenium.By$ByXPath.findElements(By.java:358)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:295)
at javaapplication4.count.linkCount(count.java:27)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:34)
Is per my understanding. After executing an alert if you try to do any other operation in the page when the alert already exists this errors comes. Are you providing the actual code?
Exception shows
at javaapplication4.count.linkCount(count.java:27)
at javaapplication4.JavaApplication4.main(JavaApplication4.java:34)
as per above stacktrace you do something in linkCount.
If you have anycode after .executeScript("alert('hello world' line. Please comment them and then check.
Related
package automationFramework;
import java.awt.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.lang.IllegalStateException;
public class Second_Practise {
public static void main(String[] args) throws InterruptedException {
String URL = "https://accounts.google.com/signin";
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "D:\\geckodriver-v0.14.0-win64\\geckodriver.exe");
driver =new FirefoxDriver();
driver.get(URL);
WebElement Email = driver.findElement(By.id("identifierId"));
Email.sendKeys("dialogspp");
WebElement Next = driver.findElement(By.id("identifierNext"));
Next.click();
Thread.sleep(2000);
WebElement myDynamicElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//*[#id='password']/div[1]/div/div[1]/input")));
WebElement Password = driver.findElement(By.xpath(".//*[#id='password']/div[1]/div/div[1]/input"));
Password.sendKeys("dialogapp");
WebElement PassNext = driver.findElement(By.id("passwordNext"));
PassNext.click();
Thread.sleep(2000);
//WebElement gmail = driver.findElement(By.xpath("//a[#href='https://mail.google.com']"));
WebElement myDynamicElement2 = (new WebDriverWait(driver, 10)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[#href='https://mail.google.com']")));
myDynamicElement2.click();
Thread.sleep(2000);
WebElement myDynamicElement3 = (new WebDriverWait(driver, 10)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[#gh='cm']")));
myDynamicElement3.click();
}
}
I am using this piece of code to send an email, but on clicking "Compose" button i am getting the exception. i.e.
Jun 20, 2017 2:57:37 PM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.xpath: //div[#gh='cm'])
org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.xpath: //div[#gh='cm']
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: '86a5d70', time: '2017-02-16 07:47:51 -0800'
System info: host: 'ANUM-PC', ip: '172.16.11.162', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$0(ExpectedConditions.java:896)
at java.util.Optional.orElseThrow(Unknown Source)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:41)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:234)
at automationFramework.Second_Practise.main(Second_Practise.java:35)
Exception in thread "main" org.openqa.selenium.JavascriptException: Error: Permission denied to access property "navigator"
Build info: version: 'unknown', revision: '86a5d70', time: '2017-02-16 07:47:51 -0800'
System info: host: 'ANUM-PC', ip: '172.16.11.162', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, appBuildId=20161031133903, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, browserVersion=47.0.2, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=Firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=Windows_NT, device=desktop, firefox_profile=UEsDBBQACAgIACp31EoAAAAAAAAAA...}]
Session ID: b216dfb9-b672-4cd2-b7cc-087c74789afa
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:315)
at org.openqa.selenium.support.ui.ExpectedConditions.elementIfVisible(ExpectedConditions.java:302)
at org.openqa.selenium.support.ui.ExpectedConditions.access$100(ExpectedConditions.java:41)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:234)
at automationFramework.Second_Practise.main(Second_Practise.java:35)
I am able to access the element using firepath but error is still been there. Any suggestions?
I am working with selenium webdriver with java.
The issue that I faced is Drag and drop not working with selenium 3 and firefox driver
I'm getting the below error:
org.openqa.selenium.UnsupportedCommandException: POST /session/92189939-94cc-4327-bfb0-72d66621d2f2/moveto did not match a known command
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'TADT063', ip: '192.168.0.195', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_20'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\Amrutha.U\AppData\Local\Temp\rust_mozprofile.l2Myb7jgbekD, rotatable=false, timeouts={implicit=0, page load=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=52.0, platformVersion=6.1, moz:processID=4308, browserName=firefox, platformName=windows_nt}]
Session ID: 92189939-94cc-4327-bfb0-72d66621d2f2
Can anybody help me?
Code :
public void selectQuestions() throws InterruptedException, AWTException {
Thread.sleep(3000);
WebElement selectquestions = webElement("VAR_SELECTTOP5QUESTIONS");
selectquestions.click();
Thread.sleep(10000);
Actions builder = new Actions(driver);
Action drag = builder.clickAndHold(webElement("VAR_SELECTQUESTIONS")).build();
drag.perform();
Point coordinates = webElement("VAR_SELECTEDQUESTIONS").getLocation();
Robot robot = new Robot();
robot.mouseMove(coordinates.getX() + 280, coordinates.getY() + 120);
Thread.sleep(3000);
WebElement questions = webElement("VAR_SELECTEDQUESTIONS");
questions.click();
Thread.sleep(1000);
WebElement questionNextButton = webElement("VAR_QUESTION_NEXTBUTTON");
questionNextButton.click();
Thread.sleep(1000);
}
I try to execute this script:
public class BuyMenShirt {
public static void main(String[] args) throws InterruptedException
{
//Firefox driver setup
String driverPath = "C:\\Users\\RW\\geckodriver-master\\";
System.setProperty("webdriver.gecko.driver", driverPath + "geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.gap.com");
WebElement menlink = driver.findElement(By.id("division5063"));
menlink.click();
WebElement shirtlink = driver.findElement(By.cssSelector("a.sidebar-navigation--category--link[href=/browse/category.do?cid=15043]"));
shirtlink.click();
}
}
However, I got this error:
Nov 01, 2016 2:10:13 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
JavaScript error: http://www.gap.com/, line 20471: TypeError: personalizationService.model.personalizationData.personalizationInfoV1.featureSelections is null
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'RW-PC', ip: '192.168.0.105', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_112'
Driver info: driver.version: RemoteWebDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20161019084923, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=1692, browserVersion=49.0.2, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 9c166d1b-3391-4ed9-8fac-3afe6d09b13f
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:622)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:465)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:430)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
at BuyMenShirt.main(BuyMenShirt.java:27)
Caused by: java.lang.IllegalArgumentException: expected one element but was: <org.openqa.selenium.remote.ErrorCodes$KnownError#cd2dae5, org.openqa.selenium.remote.ErrorCodes$KnownError#4973813a>
at com.google.common.collect.Iterators.getOnlyElement(Iterators.java:322)
at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:284)
at org.openqa.selenium.remote.ErrorCodes.toStatus(ErrorCodes.java:138)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:92)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
... 5 more
Did I do something wrong? I notice I got some JavaScript error right before UnreachableBrowserException. Does it matter?
package erewards2;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class login_sib2 {
public static void main(String[] args) {
FirefoxDriver d1 = new FirefoxDriver();
d1.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
d1.get("https://sib3.erewardsredeem.com/fm/customer.html?action=userLogin");
d1.manage().window().maximize();
WebElement e4 = d1.findElementByLinkText("Login");
e4.click();
d1.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement e1 = d1.findElement(By.id("showmemberid"));
e1.sendKeys("2800000091");
WebElement e2 = d1.findElementById("showmemberpwd");
e2.sendKeys("Miquser1");
WebElement e3 = d1.findElementByClassName("loginbtn");
e3.click();
WebElement e5 = d1.findElementByLinkText("Logout");
e5.click();
Alert a1 = d1.switchTo().alert(); //web based alert
WebDriverWait wait = new WebDriverWait(d1,10);
wait.until(ExpectedConditions.alertIsPresent()).accept();
a1.accept();
System.out.println("test1");
//close Firefox
d1.close();
System.out.println("test2");
// exit the program explicitly
System.exit(0);
System.out.println("test3");
}
}
I added the system.out println lines for test purpose and found that My code did not able to execute completely from Test1 statement. Below is the exception I got on my Eclipse IDE.
Exception in thread "main" org.openqa.selenium.NoAlertPresentException: No alert is present (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13.82 seconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'pcs-PC', ip: '192.168.1.64', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_25'
Session ID: 59fe366a-5fdc-4763-a6f2-0860bf1378be
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=30.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:610)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteAlert.accept(RemoteWebDriver.java:910)
at erewards2.login_sib2.main(login_sib2.java:40)
It looks like it fails before it gets to the close statement.
Try structuring your code like this:
FirefoxDriver d1 = new FirefoxDriver();
try {
// steps
}
finally {
d1.close();
}
This will guarantee the close statement is executed.
You can try using d1.quit() too.
I am trying to write a word in google search editbox and capture all the related list item and display it. But while doing so i got Got a exception
org.openqa.selenium.InvalidElementStateException: Element is disabled and so may not be used for actions. I went through the same exception related question and according to them changed my code but none of them help.
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class AutoIt {
public static void main(String[] args){
WebDriver window;
FirefoxProfile profile = new FirefoxProfile();
profile.setEnableNativeEvents(false);
window = new FirefoxDriver(profile);
try{
window.get("https://www.google.co.in/");
window.manage().window().maximize();
window.findElement(By.id("gs_htif0")).sendKeys("Shantanu Nandan");
window.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
List<WebElement> list=window.findElements(By.xpath("//td[#style='width: 100%;']/span"));
window.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
for(WebElement data:list){
System.out.println(data.getAttribute("value"));
}//for
}//try
catch(Exception e){
System.out.println("Got a exception");
e.printStackTrace();
window.close();
}//catch
finally{
System.out.println("Finally Block Executed ....");
window.close();
window.quit();
}//finally
}//main
}//class
Exception which i got for this code
org.openqa.selenium.InvalidElementStateException: Element is disabled and so may not be used for actions
Command duration or timeout: 47 milliseconds
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'omega-d52b83806', ip: '10.0.0.4', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_45'
Session ID: d29ef567-95a8-47ce-bf84-c510cbb2756d
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=false, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=29.0.1}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
at AutoIt.main(AutoIt.java:21)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is disabled and so may not be used for actions
Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'omega-d52b83806', ip: '10.0.0.4', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_45'
Driver info: driver.version: unknown
at <anonymous class>.fxdriver.preconditions.enabled(file:///C:/DOCUME~1/OMEGA/LOCALS~1/Temp/anonymous7567378475668954944webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:8185)
at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/DOCUME~1/OMEGA/LOCALS~1/Temp/anonymous7567378475668954944webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10814)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/DOCUME~1/OMEGA/LOCALS~1/Temp/anonymous7567378475668954944webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10831)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/DOCUME~1/OMEGA/LOCALS~1/Temp/anonymous7567378475668954944webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10836)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/DOCUME~1/OMEGA/LOCALS~1/Temp/anonymous7567378475668954944webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10778)
Finally Block Executed ....
You have selected the wrong element.
Use the below one for search text box
wb=window.findElement(By.name("q"));
Use the below for getting output suggestions.
List<WebElement> list = window.findElements(By.className("gsq_a"));
To get the values from the list, use getText() method instead of getAttribute().
for (WebElement data : list) {
System.out.println(data.getText());
}
Please try the below code
public class AutoSuggest {
WebDriver driver;
#Before
public void seup()
{
driver= new FirefoxDriver();
}
#Test
public void test_autosuggest()
{
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.google.co.in/");
driver.findElement(By.xpath("//div[#id='gs_lc0']//input[#id='gbqfq']")).sendKeys("h");
WebElement wb=driver.findElement(By.xpath("//td[#class='gssb_e']"));
List<WebElement> links= wb.findElements(By.tagName("div"));
System.out.println("the total "+links.size());
for (int i=0;i<links.size();i++)
{
System.out.println(links.get(i).getText());
}
}
}