Allowing Chrome Browser to share location details using Selenium

The below code can be used to share the geolocation details in Selenium

It does these

  • Opens the content popup in Chrome
  • Clicks on the radio button – share the location details
  • Then Click on Ok

 

Browser.Navigate().GoToUrl("chrome://settings/content"); 
Browser.SwitchTo().Frame("settings"); 
var location = Browser.FindElement(By.XPath("//input[@name='location' and @value='allow']"),LongWaitTime); Browser.ExecuteScript("arguments[0].click();", location); 
Browser.FindElement(By.XPath("//*[@id='content-settings-overlay-confirm']"), LongWaitTime).Click();

 

You may also like...