0

enter image description here

I have to take cursor on "Tickets" link and then click on the "Statuses". As soon as i take cursor outside this window/frame this screen gets closes and i again have to take cursor on "Tickets" link.

HTML is:- enter image description here enter image description here

RAHUL
  • 398
  • 1
  • 6
  • 15
  • I don't find the element with text as **Tickets** in the spashot. Additionally, please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). You may like to consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Feb 17 '23 at 20:36
  • added the html for "tickets" – RAHUL Feb 17 '23 at 20:38

1 Answers1

0

To Mouse Hover over the element with text as Tickets and then to click on the element with text as Statuses you can use the following locator strategies:

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
WebElement tickets = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@title='Tickets']")));
Actions actions = new Actions(driver);
actions.moveToElement(tickets).build().perform();
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Statuses"))).click();

Optimizing the code you can use:

new Actions(driver).moveToElement(new WebDriverWait(driver, Duration.ofSeconds(5)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@title='Tickets']")))).build().perform();
new WebDriverWait(driver, Duration.ofSeconds(5)).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@class='ember-view' and text()='Statuses']"))).click();
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • i am getting an error:- java: incompatible types: java.time.Duration cannot be converted to long – RAHUL Feb 17 '23 at 21:47
  • Nopes, why would you convert it to `Duration.ofLong()`? Not needed really, use as it is `Duration.ofSeconds(5)`. Seems your framework issue. – undetected Selenium Feb 17 '23 at 21:52