Reputation: 644
I'm trying to click on each of these buttons but I'm failing to get anything. Even xpath is failing to pick them up. Does anyone have any idea on how to locate these buttons?
<button class="rt-button rt-dialog-button" title="" value="">Close</button>
<button class="rt-button rt-dialog-button" title="" value="">OK</button>
Many thanks for any help
EDIT:
Thanks for trying to help. None of the suggestions worked for me but I did sort it out using:
c#
IWebElement OKButton = driver.FindElement(By.XPath(("//button[@class='rt-button rt-dialog-button'][2]")));
IWebElement CloseButton = driver.FindElement(By.XPath(("//button[@class='rt-button rt-dialog-button'][1]")));
Upvotes: 1
Views: 2735
Reputation: 16201
//[.='OK']
if this does not work then you have multiple elements having same text hidden or somewhere on the page
Upvotes: 0
Reputation: 9029
I'd use xpath to find them:
By.XPath("//button[text()='Close']")
By.XPath("//button[text()='OK']")
Upvotes: 3
Reputation: 59
You can add an ID, to each element.
<button id="closeButton" class="rt-button rt-dialog-button" title="" value="">Close</button>
<button id="okButton" class="rt-button rt-dialog-button" title="" value="">OK</button>
Then to find it you can do something like
IWebElement element = driver.FindElement(By.Id("closeButton"));
IWebElement element = driver.FindElement(By.Id("openButton"));
I have had times where I was having a hard time with capturing by class and x-path and ID helped.
Upvotes: 0