Reputation: 67
I have searched for an Account in Salesforce and it gives a few search results. But I'm unable to find the element in Selenium.
I have tried using absolute/relative xpath
and CSSSelector
, LinkText
as well.
Used: driver.findElement(By.linkText("ILT_Order1")).click();
<a href="javascript:srcUp(%27%2F0010C000003HmzI%3FsrPos%3D0%26srKp%3D001%26isdtp%3Dvw%27);" data-seclke="Account" data-seclkh="b2e6250471c982c9bec58d55cc1e0f42" data-seclki="0010C000003HmzI" data-seclkp="/0010C000003HmzI" data-seclkr="1" onmousedown="searchResultClick.mousedown(this, event)">ILT_Order1</a>
I am unable to find the element.
Upvotes: 0
Views: 127
Reputation: 193108
As the element is a JavaScript enabled element so to click()
on the element you need to use elementToBeClickable()
and you can use either of the following Locator Strategies:
linkText
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.linkText("ILT_Order1"))).click();
cssSelector
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a[data-seclke='Account'][onmousedown^='searchResultClick'][href]"))).click();
xpath
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@data-seclke='Account' and text()='ILT_Order1'][starts-with(@onmousedown, 'searchResultClick')]"))).click();
Upvotes: 0
Reputation: 33384
Induce WebDriverWait
and elementToBeClickable
and following xpath.
If still not found then check if there any iframe
available on the page.
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@data-seclke='Account'][text()='ILT_Order1']")));
element.click()
Upvotes: 1