So, I was trying out a test case on a website and Selenium registers the events perfectly. Now, if I have to search for a particular class and get the innerHTML of that class, how would I do it assuming that I am using Java as the driving language?
Just to be more clear. I have a class like this:
<h1 class="classname">.....</h1>
I want to get the entire text between those tags.
And finally, if the ids of the buttons on the page are dynamically generated, how would I test the cli开发者_开发技巧cking action on them? These button, I presume are using ajax. When I click on the button, Selenium generates this:
//div[@id='c4aef94de622f51859827294']/div/div/div[1]/span[2]/span/span[3]/a
and the actual HTML of the button is this:
<a href="#" bindpoint="forward" class="ButtonForward"/>
Is it even possible to click on the button?
You could use the getHtmlSource
command to get the entire HTML source, and then use something else to parse the HTML in Java and extract the contents of the target element.
You can locate elements without using an ID, for example if this is the only such button on the page you could locate it:
Using CSS locators:
selenium.click("css=a.ButtonForward");
Using XPath locators:
selenium.click("xpath=/descendant::a[@class='ButtonForward']");
精彩评论