Reputation: 5231
This is my html code:
<a href="guestProfile.do?reloadGuest=true&gmp=42017073774&resConf=400007053&roomSeq=1&rrsId=1&propId=712" target="sgr" <a="" name="Y">YIKKU, TFYTUR</a>
I want to click on the link name YIKKU TFYTUR, i have tried the following but nothing worked-
driver.findElement(By.partialLinkText("YIKKU, TFYTUR")).click();
driver.findElement(By.cssSelector("a[href*='Y']")).click();
can anyone please help me??
Upvotes: 0
Views: 3007
Reputation: 5231
The only solution to these kind of Href tags are find the nearest "id" element, in my case was this-
<table id="resSearchResultsTBL">
then find this element using css selector:
WebElement guest = driver.findElement(By.cssSelector("table[id='resSearchResultsTBL']"));
and then find again in this element a sub element of "a href" tag:
guest.findElement(By.cssSelector("a[href*='guestProfile.do']")).click();
This worked perfectly for me.:)
Upvotes: 2
Reputation: 2507
Try -
WebElement link = driver.findElement(By.xpath("//a[@name=\"Y\"]"));
wait.until(ExpectedConditions.elementToBeClickable(link));
link.click();
or
WebElement link = driver.findElement(By.xpath("//a[@target=\"sgr\"]"));
wait.until(ExpectedConditions.elementToBeClickable(link));
link.click();
Upvotes: 1