I am running Selenium to test a specific area of my companies webpage. What I am trying to do seems relatively easy in theory, but I have ran into several obstacles. Can someone please tell me why the URL is opening but won't select the "Services" Hyperlink?
Below is a snippet of the code:
System.setProperty("webdriver.ie.driver","Path to IE/IEDriverServer_64.exe");
WebDriver driver = new InternetExplorerDriver();
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
driver.get("https://www.ups.com/us/en/Home.page");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*/div[@id='ups-header']/nav[@id='ups-navItems']/ul[@class='ups-navItems_primary']/li[@class='ups-navMenu ups-menu'][3]/a[@id='ups-menuLinks2']")).click();
As I stated earlier, in theory this should open up UPS's homepage and select the "Services" tab on the top right of the page. Instead it just goes to UPS.com homepage and stays there.
I have driver.findElement(By.xpath........); in this example but I have tried findElement(By.name & partialLinkText
Can anyone give me a solution besides update to latest version(s)?
Metadata: Windows 10, JAVA 10, Internet Explorer (Unfortunately) 11.4.
Thanks in advance!
Edit with additonal HTML structure:
This is a portion of the HTML I am working with. This HTML belongs to the Services link I want to click in my automation:
<a role="button" href="#" class="ups-analytics ups-menu_toggle" data-
content-block-id="M1" data-event-id="22" aria-expanded="false" id="ups-
menuLinks2" aria-controls="ups-menuPanel2">Services<span class="ups-mobnav-
arrow" aria-hidden="true"></span></a><div class="ups-menu_list ups-cols-3"
aria-hidden="true" role="region" id="ups-menuPanel2" aria-labelledby="ups-
menuLinks2">
<h2 class="ups-med_show">Services</h2>
<div class="ups-menu_listCols">
Internet Explorer v11 doesn't opens the url on my system but with Selenium v3.12.0, ChromeDriver 2.39 and Chrome v67.0 the following solution clicks on the element with text as Services just perfecto:
Code Block:
Browser Snapshot: