How to select data from google address in text field in Selenium WebDriver

48 views
Skip to first unread message

Rashmi Upari

unread,
Mar 5, 2019, 3:47:27 AM3/5/19
to Selenium Users
Hello All,

How to select data that is populated from google address.
Tried select option but its not working

WebElement add1= driver.findElement(By.xpath("//*[@id=\"user-account__address1\"]"));

add1.clear();

add1.sendKeys("100100 Brewster Rd");

Thread.sleep(100);

WebDriverWait a = new WebDriverWait(driver,100);

a.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("/html/body/div[49]")));

WebElement b=driver.findElement(By.xpath("/html/body/div[49]/div[1]"));

Select s1=new Select(b);

List<WebElement> opt=  s1.getOptions();

System.out.println(opt);


Screenshot 2019-03-05 at 2.15.14 PM.png

Rashmi Upari

unread,
Mar 5, 2019, 3:49:44 AM3/5/19
to Selenium Users
<div class="pac-container pac-logo" style="width: 616px; position: absolute; left: 332px; top: 721px; display: none;"><div class="pac-item"><span class="pac-icon pac-icon-marker"></span><span class="pac-item-query"><span class="pac-matched">100100</span> <span class="pac-matched">Brewster Rd</span></span><span>Newark, NJ, USA</span></div><div class="pac-item"><span class="pac-icon pac-icon-marker"></span><span class="pac-item-query">100100 <span class="pac-matched">Brewster Rd</span></span><span>Medford, MA, USA</span></div><div class="pac-item"><span class="pac-icon pac-icon-marker"></span><span class="pac-item-query">100100 <span class="pac-matched">Brewster Rd</span></span><span>Preston, CT, USA</span></div><div class="pac-item"><span class="pac-icon pac-icon-marker"></span><span class="pac-item-query">100100 <span class="pac-matched">Brewster Rd</span></span><span>Birmingham, AL, USA</span></div><div class="pac-item"><span class="pac-icon pac-icon-marker"></span><span class="pac-item-query">100100 <span class="pac-matched">Brewster Rd</span></span><span>Oakland charter Township, MI, USA</span></div></div>

Rashmi Upari

unread,
Mar 5, 2019, 4:31:07 AM3/5/19
to Selenium Users
I was able to solve it with Actions method

WebDriverWait a = new WebDriverWait(driver,100);

a.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("/html/body/div[49]")));

WebElement b=driver.findElement(By.xpath("/html/body/div[49]/div[1]"));

Actions act = new Actions(driver);

act.click(b).build().perform();


On Tuesday, 5 March 2019 14:17:27 UTC+5:30, Rashmi Upari wrote:
Reply all
Reply to author
Forward
0 new messages