How to handle Google Autofill Suggestion

Hello Team,

Our application has a functionality to auto-fill the Shipping Address and Billing Address based on the Initial Entry in the Address field by User. I was searching this forum and found out there isn’t much success in terms of handlign that Autofill. If I am wrong here please help me in figuring out how to handle that AutoFill. Here is my detailed requirement about that autofill and how I am planning to use that.

  1. Once the user is on the Checkout page where they are supposed to enter there Shipping address and on Address Feild when they start typing there address Google throws some suggestions. I want to select the select the first given suggestion.

  2. On the address field Step, the script will add a random number between 1 to 9999 and based on that number Google autofill will throw suggestions. I would like to select the 1st entry in suggestion.

This would make my test cases more dynamic in terms of test data. Currently, I am just pushing one single address in every test case.

Hi @manpreet.mukkar

If you can simulate the user action (Using Javascript or WebUI keyword) that triggers such a pop-up or auto-fill, then it may be possible to automate it. Could you try it out and report where you get stuck ?

It’s hard to come up with things from scratch, so you need to try it out first and let us see the difficulties.

Regards !

1 Like

Hello @ThanhTo

I took your advice and actually tried by myself and it worked. Before this, I was just taking into consideration that I won’t be able to do it myself.

I created an object and used default click which is basically clicking on the very 1st suggestion given by Google. A step before that is adding a random 4 digit number to trigger Google Suggestion. This way now I don’t have to hardcode any address. Every test will generate a random address.

1 Like

Hi @manpreet.mukkar
In my web app to select city, google API is integrated and I am trying to automate that using katalon but after auto-populates of location when I pick up one location it is not selecting. Can you please explain how you solved your issue

@manasa2 Once the Suggestions are triggered based on your input in the field then you need to capture the selector for 1st suggestion.That selector needs to be added using the click command.

You would need to capture the suggestion selector manually for 1st time and add that to object.

That would basically simulate the click on Google Suggestion.

Something like this :

int Google_Suggestion = ((org.apache.commons.lang.RandomStringUtils.randomNumeric(9999)) as int)

WebUI.sendKeys(findTestObject('Customer_Information_Page/Field_Address'), Google_Suggestion)

WebUI.delay(GlobalVariable.MediumDelay)'Customer_Information_Page/Selecting_Google_Autofill_Suggestion'), FailureHandling.STOP_ON_FAILURE)

You will see in the script I am generating a 4 digit random integer that would be entered in the Autofill field. This would trigger Google suggestion.

1 Like

@manpreet.mukkar When I entered text in the city field auto-populate of cities based on entered text is not showing when I run my code

@manasa2 There might be a problem with selector for that field, Can you please show the HTML of that field and also your script ?


You can find the HTML code of that field in below attachement

HTML.txt (4.2 KB)

@manasa2 I need a screenshot of element highlighting its html using dev tools

Or, If it is a public facing website and you are fine with sharing it please share the URL.

@manpreet.mukkar These are the Screenshots of the HTML code. Can you please check on let me known the solution

@manasa2 It looks like your object selector may be having some issue, You should try using Choropath in this case, the object looks very simple to me.

Or else try using id = mat-input-6. ID is supposed to be unique at it looks so to me here.