Selenium Webdriver-Unable to click on link having normalized space.

Browser-IE8
I have a scenario in which
Click on Customers>>>Pull down menu appears

Click on Customer Search

I am not able to click on Customer Search

Screenshot of HTML code attached

Earlier I was having some issue in finding HTML code the element because of normalized space.
I am able to click on Customers with the following code snippet

WebElement cust = driver

.findElement(By
.xpath(“//span[contains(@class,’middle’)and normalize-space(.)=’Customers’]”));
Able to click on customers

Selenium Webdriver-Unable to click on link having normalized space.

Not able to click on Customer Search
Selenium Webdriver-Unable to click on link having normalized space.

Able to Click on Customers under span tag
Selenium Webdriver-Unable to click on link having normalized space.

Not ABLE TO CLICK ON Customer Search under anchor tag
Selenium Webdriver-Unable to click on link having normalized space.

Some of code tried  for Customer Search  which is not working


driver.findElement(By.xpath(“//a[@id=’OfferingAnchorTag0′ and normalize-space(.)=’CustomerSearch’]”)).click();

driver.findElement(By.partialLinkText(“tomer Search”)).click();

 

Aakash Default Asked on May 6, 2015 in Selenium WebDriver.
Add Comment
1 Answer(s)

In the last code segment. It seems that your xpath to the a tag is wrong. Just use till >("//a[@id='OfferingAnchorTag0]') I dont know why you have extra text there.

Virender Singh Professor Answered on May 6, 2015.

Hi Virender, The id=offereningAnchorTag0 is not the only id having this name.There are three more Id with same name on the page. So i have to be more specific to find the Customer Search . Customer search  id i,e,  id=offereningAnchorTag0  is the first id on the page.So if i am using this expressionWebElement abc=driver.findElement(By.xpath(//a[contains(@id=’OfferingAnchorTag0])’))>>>>>>>>>>>>>>Able to pass but Getting exception ElementNotVisibleException on  abc.click();//tried to use WebdriverWait and JavascriptExexutor but getting same exception//a[@id=’OfferingAnchorTag0]’) >>>>>>>>>>>>>>>>>>>>>>Getting Exception 

on May 12, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.