Trying to select a list item with Watir

338 Views Asked by At

I am unable to select a list element when I click on the link I get the list to appear which should make the style display block visible however watir cannot find the element and times out.

Here is a sample of the code just showing one list item but they are all the same. The unique aspect would be the text. "Machine Translation"

<a id="addQuality" data-toggle="tooltip" data-placement="top" title="" data-original-title="Add New Output Quality">
<ul id="addQualityList" class="dropdown-menu" style="display: none;">
<li id="3d3c4316-b8ad-45bf-b8be-03ee69452deb" class="dropdown-menu-list addQualityTabItem add-quality-dropdown" data-url="/Client/AddContractTranslationQuality?id=255b9627-5452-4b6a-af46-084af684ff27&qualityId=3d3c4316-b8ad-45bf-b8be-03ee69452deb&prefix=Contracts[43c13738-abc4-42e1-89b1-7211d581e4be]">Machine Translation</li>


@b.link(:id => "addQuality").click # This will display the list
@b.select_list(:id => "addQualityList").option(:text =>   "Presentation").when_present.select

and I tried...

@b.select_list(:id => "addQualityList").when_present(2).click
1

There are 1 best solutions below

0
On

I was able to come up with a solution. If anyone has another that is more elegant please post. Thanks.

@b.link(:id => "addQuality").click
@b.div(:class => "col-md-12").ul.li(:text => "Publication").click