How to scroll down and select items in Google Maps

AMER SAID 396 Reputation points
2023-02-10T17:59:42.3766667+00:00

hi

How to scroll down and select items in Google Maps

use Selenium + WebDrive version 109.0.5414.74 for Google Chrome to explore within Google Maps. I read the selected item to scroll to the bottom of the page. The scroll takes only a few centimeters and does not scroll to the last item to display all the selected items.

It is required to modify the code so that it goes down to the bottom of the page and returns again to the first element to list the elements.

Untitled

Untitled1

foreach (var item in driver.FindElements(By.XPath("//*[@id='QA0Szd']/div/div/div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]"))) {

            driver.FindElement(By.XPath("//*[@id='QA0Szd']/div/div/div[1]/div[2]/div/div[1]")).Click();
            Actions actions = new Actions(driver);
            actions.SendKeys(OpenQA.Selenium.Keys.PageDown).Build().Perform();
         
        }

code to click item one by one after scrole end


 foreach (var item in driver.FindElements(By.XPath("//*[@id='QA0Szd']/div/div/div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]")))
            {

                if (item.Text != "")
                {
                  
                    item.Click();
                    MessageBox.Show(item.Text);
                }

            }
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,339 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.