Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • About Us
  • Toggle search form

Selenium Code Practice – Get All Product Names Of Google Home Page

Posted on 02/19/2025 By admin

This selenium scripting question is asked to beginners and intermediate-level professionals. The detailed problem statement is as below:-

  1. Launch Google Home page URL.
  2. Click on “Google Apps” Icon.
  3. Print all product names.

This looks simple but it has multiple Selenium concepts involved and that makes this question perfect for interviews.

Did you know that I have started a YouTube channel as well and I need your support to make it successful. Please do watch content then comment, like, share, and obviously subscribe.

  1. Locating SVG elements in Selenium WebDriver.
  2. Switch to IFrame in Selnium WebDriver.
  3. Locating multiple web elements
  4. Little complex Xpaths
  5. Stream Apis in Java
package General; import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test; import io.github.bonigarcia.wdm.WebDriverManager; public class GetAllGoogleAppNames { @Test public void navigateThroughTabsAndGetTitle() { // Launching browser WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); // Loading Google driver.get("https://www.google.com/"); // Google Apps is a SVG element. There are multiple svg element so I used multiple attributes. driver.findElement(By.xpath("//*[name()='svg' and @class='gb_We']")).click(); // App names are shown in under an IFrame driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@role='presentation']"))); // Locating all app names. XPath is tricky as we can not use their values as they are dynamic List allMenus = driver.findElements(By.xpath("//div[@jsname and @jsaction]//li/a/span")); // Printing all app names Without stream for(WebElement menu : allMenus) { System.out.println(menu.getText()); } System.out.println("===================================================="); // With stream apis allMenus.stream().map(WebElement::getText).forEach(System.out::println); //quitting driver driver.quit(); } }
Account
Search
Maps
YouTube
Play
News
Gmail
Meet
Chat
Contacts
Drive
Calendar
Translate
Photos
Duo
Shopping
Docs
Sheets
Slides
Books
Blogger
Hangouts
Keep
Jamboard
Earth
Collections
Arts and Culture
Google Ads
Podcasts
Travel
Forms
====================================================
Account
Search
Maps
YouTube
Play
News
Gmail
Meet
Chat
Contacts
Drive
Calendar
Translate
Photos
Duo
Shopping
Docs
Sheets
Slides
Books
Blogger
Hangouts
Keep
Jamboard
Earth
Collections
Arts and Culture
Google Ads
Podcasts
Travel
Forms

You can subscribe to my YouTube channel RetargetCommon to learn from video tutorials.

If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading

#HappyLearning

Uncategorized

Post navigation

Previous Post: Postman Tutorial Part 12 – Understand Environment & Variables in Postman
Next Post: Difference Among isDisplayed(), presenceOfXXX() and visibilityOfXXX() Methods In Selenium Webdriver

Related Posts

OverloadedResult – Make Selenium Easy Uncategorized
alertPopup – Make Selenium Easy Uncategorized
image – Make Selenium Easy Uncategorized
Cucumber Tutorial 1 – Setup a Basic Maven-Cucumber 5 -Junit Project in Eclipse Uncategorized
Introduction Of Page Object Model In Selenium WebDriver: Advantages And disadvatages Uncategorized
LatestRun – Make Selenium Easy Uncategorized

Recent Posts

  • How to Set Up Selenium WebDriver with Python Step by Step
  • How to Set Up Selenium WebDriver with Java from Scratch
  • What Is Selenium and Why It Is the Most Popular Test Automation Framework
  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark