Hi Justin/Titus

Facing another challenge here.

I have a section of a page with multiple outer div which has lots of inner 
divs/spans etc of which Im interested in a select with an attribute named 
"data-product-id" which has a specific value.

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid" id=
"dwfrm_cart_shipments_i0_items_i0_quantity" name=
"dwfrm_cart_shipments_i0_items_i0_quantity" data-product-id="9350486558733" 
data-item-position="1" aria-invalid="false">
<option value="1" selected="selected">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid" id=
"dwfrm_cart_shipments_i0_items_i0_quantity" name=
"dwfrm_cart_shipments_i0_items_i0_quantity" data-product-id="9350486558734" 
data-item-position="1" aria-invalid="false">
<option value="1" selected="selected">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<div class="row cart-product-row ">
----
----
----
<select class="input-select has-value custom-input valid" id=
"dwfrm_cart_shipments_i0_items_i0_quantity" name=
"dwfrm_cart_shipments_i0_items_i0_quantity" data-product-id="9350486558735" 
data-item-position="1" aria-invalid="false">
<option value="1" selected="selected">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>



My requirement is to find the select element with a particular value of 
"data-product-id" attribute and set it to say 2

Any clue on how to achieve this?


On Wednesday, 11 July 2018 13:48:56 UTC+10, NaviHan wrote:
>
> Hi Justin
>
> That worked like a charm. PageObject gem is amazing :-)
>
> On Tuesday, 3 July 2018 21:48:19 UTC+10, NaviHan wrote:
>>
>> This is my first post here. Apologies if there is a mistake.
>>
>> I have a section of a page as attached in the pic.
>>
>>
>> The html code for the section is as follows
>> Enter code here...<div class="small-12 applied-evouchers">
>> <div class="row applied-voucers-list">
>> <div class="small-6">
>> <span>9830318220466018</span>
>> </div>
>> <div class="small-6 small-text-right"> 
>> <button type="button" class="remove-gift-cert" 
>> data-gift-id="9830318220466018">
>> <span class="icon icon-cross-standard-small-black"></span>
>> <span class="underline remove-evoucher-button-text">Remove</span>
>> </button>
>> </div>
>> </div>
>> <hr>
>> <div class="row applied-voucers-list">
>> <div class="small-6">
>> <span>9831228610400260</span>
>> </div>
>> <div class="small-6 small-text-right"> 
>> <button type="button" class="remove-gift-cert" 
>> data-gift-id="9831228610400260">
>> <span class="icon icon-cross-standard-small-black"></span>
>> <span class="underline remove-evoucher-button-text">Remove</span>
>> </button>
>> </div>
>> </div>
>> <hr>
>> </div>
>>
>> I need to assert two value here
>>
>> 1. The vouchers applied, which are 9830318220466018 & 9831228610400260
>> 2. The span "Remove"
>>
>> The issue Im facing is as these two divs are identical and 1 & 2 doesnt 
>> have a unique identifier I cannt locate them using PageObjects.
>>
>> I can locate the element using the following Java script
>> document.getElementsByClassName('applied-voucers-list')[0].innerText;
>> This returns 
>> Enter code here..."9830318220466018
>> Remove
>> "
>>
>> I tried to capture this with the code
>> Enter code here...@var = 
>> @browser.execute_script("document.getElementsByClassName('applied-voucers-list')[0].innerText;")
>>
>> This isnt working
>>
>> Any clue?
>>
>>

-- 
-- 
Before posting, please read 
https://github.com/watir/watir_meta/wiki/Guidelines-for-Posting-to-Watir-General-Google-Group.
 
In short: search before you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to