I am writing scripts in Ruby that supports Capybara. I will have to select a value from a dropdown list box and I am using "xpath" to find the element and make the selection.
The code is given below:
<select class="sortOrder fsm textCatalogTitleBlack" style="width: 150px;">
<option value="/all-products/?sort=popularity&dir=desc"> Sản phẩm ưa chuộng </option>
<option value="/all-products/?sort=name&dir=asc"> Tên </option>
<option selected="selected" value="/all-products/?sort=price&dir=asc"> Giá </option>
<option value="/all-products/?sort=brand&dir=asc"> Thương hiệu </option>
<option value="/all-products/?sort=latest arrival&dir=desc"> Mới nhất </option>
<option value="/all-products/?sort=discount&dir=desc"> Giảm giá </option>
</select>
I will need to select "Giá" from the above list-box.
I have written the code as
find(:xpath, "//select[@class='sortOrder.fsm.textCatalogTitleBlack']/option[@text=' Giá ']").click
Result:
Unable to find xpath "//select[@class='sortOrder.fsm.textCatalogTitleBlack']/option[@text=' Giá ']" (Capybara::ElementNotFound)
Please help. Is there any problem with the syntax?