Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am able to <strong>Save</strong> to <strong>My Maps</strong> link with following code given in below screen shot.</p> <p>There is no need to have a recorded step to scroll down the panel, Selenium can locate and do actions on any web object in a Web page without being visible to the user.</p> <p><img src="https://i.stack.imgur.com/orpTJ.jpg" alt="enter image description here"></p> <p><strong>Details of the code:</strong></p> <p>Line6: <strong>Command-</strong> waitForVisible <strong>Target-</strong> //div[@id='dir_sr']/a[@id='srlink'] </p> <p>I have added <strong>waitForVisible</strong> so that Selenium will wait for 5 seconds before the link <strong>Save to My Maps</strong> is visible. This will give enough synchronization time for the page to load after pressing the <strong>Get Directions</strong> button. <strong>//div[@id='dir_sr']/a[@id='srlink']</strong> is the XPath locator for link <strong>Save to My Maps</strong></p> <p>Line7: <strong>Command-</strong> click <strong>Target-</strong> //div[@id='dir_sr']/a[@id='srlink'] </p> <p>Click on link <strong>Save to My Maps</strong></p> <p>Line8: <strong>Command-</strong> click <strong>Target-</strong> //button[@id='srsave']</p> <p>Click on button <strong>Save</strong></p> <p>C#.Net WebDriver code for the same. Note that Google account User Name and Password has to be provided to save the map link.</p> <pre><code>using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { public class GoogleMapSavingTest { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); driver.Navigate().GoToUrl("https://maps.google.com.au/"); driver.FindElement(By.Id("d_launch")).Click(); driver.FindElement(By.Id("d_d")).Clear(); driver.FindElement(By.Id("d_d")).SendKeys("Franklin, ACT"); driver.FindElement(By.Id("d_daddr")).Clear(); driver.FindElement(By.Id("d_daddr")).SendKeys("Gungahlin, ACT"); driver.FindElement(By.Id("d_d")).Click(); driver.FindElement(By.Id("d_sub")).Click(); for (int second = 0;; second++) { if (second &gt;= 60) Assert.Fail("timeout"); try { if (driver.FindElement(By.XPath("//div[@id='dir_sr']/a[@id='srlink']")).Displayed) break; } catch (Exception) {} Thread.Sleep(1000); } driver.FindElement(By.XPath("//div[@id='dir_sr']/a[@id='srlink']")).Click(); driver.FindElement(By.Id("Email")).SendKeys("UserName"); driver.FindElement(By.Id("Passwd")).SendKeys("Password"); driver.FindElement(By.Id("signIn")).Click(); for (int second = 0; ; second++) { if (second &gt;= 60) Assert.Fail("timeout"); try { if (driver.FindElement(By.XPath("//div[@id='dir_sr']/a[@id='srlink']")).Displayed) break; } catch (Exception) { } Thread.Sleep(1000); } driver.FindElement(By.XPath("//div[@id='dir_sr']/a[@id='srlink']")).Click(); driver.FindElement(By.XPath("//button[@id='srsave']")).Click(); } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload