Drupal8 Logout Link at footer ( XPath vs LinkText )
- Had MUCH difficulty hooking into the logout link using XPATH for
- JS window.scrollTo
- By.LinkText(“Log out”) seems to be more accessible
- using By.LinkText allowed Selenium to natively 'scroll to' on the 'Click()' method
Selenium basic selectors
XPath
el = driver.FindElement(By.XPath("//a[@href='/uc/user/logout']"));
Id
el = driver.FindElement(By.Id("username"));
LinkText
el = driver.FindElement(By.LinkText("Log out"));
JS scrollIntoView
- when element found by XPath(//a), this didn't work
el = driver.FindElement(By.LinkText("Log out"));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", el);
ILoc