Hi,
I tried using the Xpath locator with regular expression and it is not working and displays the following msg
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector"..
I saw a post something related to my issue as stated below. But it seems that Xpath locator with regular expression will not work properly as few browsers could not support it. But Im using FF20, IE10, Chrome latest version.
Pls find below the details of my issue
I've few similar fields that belongs to two different versions of an application.
For eg.
Uc2_centerContent1_Uc2_nameDetails1_ApplicantNameFields_day (version 1)
Uc2_centerContent1_Uc2_evoFields1_day (version 2)
Uc2_centerContent1_Uc2_nameDetails1_ApplicantNameFields_mon (version 1)
Uc2_centerContent1_Uc2_evoFields1_mon (version 2)
Uc2_centerContent1_Uc2_nameDetails1_ApplicantNameFields_year (version 1)
Uc2_centerContent1_Uc2_evoFields1_year (version 2)
And the field above is nothing but a Date of Birth fields. And eventually these have a matching pattern for each of individual fields which we can put it in the following way
Uc2_centerContent1_Uc2.*day
Uc2_centerContent1_Uc2.*mon
Uc2_centerContent1_Uc2.*year
I tried using the following method for just one field to check if it works or not. But unfortunately it is not working
new Select(SeleniumDriverClass.driver.findElement(By.xpath("//div/select[matches(@id, 'Uc2_centerContent1_Uc2.*day')]"))).selectByVisibleText("10");
new Select(SeleniumDriverClass.driver.findElement(By.xpath("//div/select[contains(@id, 'Uc2_centerContent1_Uc2.*day')]"))).selectByVisibleText("10");
Not too sure the other ways of implementing the regular expression
Can anyone suggest me to resolve this soon as i got stuck in the middle of something important.
Thanks,
Brad