Cannot read property 'defaultView' of undefined
Try click on its parent/ancestor instead. For example, if you had
//a[text()='link of your text']
and you get the javascript error, try:
//a[text()='link of your text']/parent::*
To click on the following link use WebDriverWait
and elementToBeClickable
and then click on the link using the following xpath.
WebDriverWait wait = new WebDriverWait(driver, 15);wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@title='Country']/span[@class='slds-truncate'][contains(.,'Country')]"))).click();
Try the following code - it works against Salesforce Lightning UI screens:
WebElement element = driver.findElement(By.xpath("your xpath")); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", element);
Sharing it after testing it and found to be working.