I am a newbie to java and selenium. I am having an issue in clicking a link with javascript in href. Below is the page source:
href="javascript:navigateToDiffTab('https://site_url/medications','Are you sure you want to leave this page without saving your changes?');" tabindex="-1">Medications
Please note: I replaced actual url with "site_url" because of business concerns.
I tried below code but it did not work:
driver.findElement(By.cssSelector("a[href^='javascript:navigateToDiffTab'][href$='site_url/medications']")).click();
I do not want to use id or linkText as those changes with different environments and languages.
Any help would be much appreciated.