How to scroll down and select items in Google Maps
AMER SAID
396
Reputation points
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.
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);
}
}
Sign in to answer