thanks for taking the time to read this (as always)
Im currently updating automation (Java, selenium webdriver) for a new module in our web application, I have a few tabs & I'm wondering what the best approach to testing their active-state would be, In short - There is 3 tabs within the module, 2 of which are only accessible when you are selecting a pre-existing Survey (Module = Surveys)
The three tabs in question are: General Details, Questions & Activity I need to test the following:
- Without selecting existing - Questions & Activities are not accessible
- When selecting an existing - All three tabs are accessible
<div id="divTabs">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist">
<li class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="fragment-1" aria-labelledby="ui-id-1" aria-selected="true" aria-expanded="true">
<a id="ui-id-1" class="ui-tabs-anchor" href="#fragment-1" role="presentation" tabindex="-1">
<span id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderSurvey_lblGenDetailsTab">General Details</span>
</a>
</li>
<li class="ui-state-default ui-corner-top ui-state-disabled" role="tab" tabindex="-1" aria-controls="fragment-2" aria-labelledby="ui-id-2" aria-selected="false" aria-expanded="false" aria-disabled="true">
<a id="ui-id-2" class="ui-tabs-anchor" href="#fragment-2" role="presentation" tabindex="-1">
<span id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderSurvey_lblQuestionsTab">Questions</span>
</a>
</li>
<li class="ui-state-default ui-corner-top ui-state-disabled" role="tab" tabindex="-1" aria-controls="fragment-3" aria-labelledby="ui-id-3" aria-selected="false" aria-expanded="false" aria-disabled="true">
<a id="ui-id-3" class="ui-tabs-anchor" href="#fragment-3" role="presentation" tabindex="-1">
<span id="ctl00_ctl00_MainContentPlaceHolder_MainContentPlaceHolderSurvey_lblActiveSurveysTab">Activity</span>
</a>
</li>
</ul>
</div>
I thought about just checking that "Title" exists after attempting to click the tabs, thinking if that tab was shown it would struggle to find the label on the general details tab, however that is failing, guess it is still accessing that title & returning true regardless.
I tried something along the lines of this:
driver.findElement(By.id("ui-id-2")).click();
if (titleLabel.equals("Title"))
{
iCounter++;
}
driver.findElement(By.id("ui-id-3")).click();
if (titleLabel.equals("Title"))
{
iCounter++;
}
assertThat(iCounter, equalTo(2));
but evidently, that was a pretty terrible approach to it Thanks alot
Aucun commentaire:
Enregistrer un commentaire