Case Study: Google Maps Address Validation

How to use Google Map’s validated address fields to enter and pick an address

Courtney Zhan

--

This is included in Selenium Training Workbook on SubStack. I wrote based on my father’s training slides and test scripts.

Learning Objectives

  • Write a simple Create Client test in Selenium WebDriver
  • Refactoring in TestWise (Extract Page Function)
  • Enter and Select Autofilled Address by Google Maps

Task 26.1: Add a new Client

This should be familiar to readers who followed lesson 22 of this series— this is just the Create step of CRUD.

Follow the steps in lesson 22 and the above task card to log into the test site (https://whenwise.agileway.net) and add a client.

Remember to skip the address field (i.e. leave it blank and only fill in the other fields for now). We will get to this in part 2 of today’s lesson.

Your test case might look like the one below.

it "Add new Client" do
# after login
driver.get("https://whenwise.agileway.net/clients"
driver.find_element(:id, "new_client_link").click
driver.find_element(:id, "calendar_client_first_name").send_keys("Dom")
driver.find_element(:id, "calendar_client_last_name").send_keys("Smith")
driver.find_element(:id, "calendar_client_mobile").send_keys("0431868588")
driver.find_element(:id, "calendar_client_email").send_keys("dom@gmail.com")
driver.find_element(:id, "client_notes").send_keys("Hi")
driver.find_element(:id, "create_calendar_client_button").click
expect(page_text).to include("Dominic")
end

The above script works, but is hard to maintain (and read). Refactor it.

Check out this article for more details or see previous lessons. To start, highlight the first operation step to be moved into a page, e.g. driver.find_element(:id, “new_client_link”).click, then invoke TestWise’s ‘Extract to Page Function …’ refactoring.

--

--