I have this HTML
<div class="ui-widget">
<select name="calAlum" style="display: none;">undefined
<option value=""></option>
<option value="5.0">5.0</option>
<option value="5.1">5.1</option>
<option value="5.2">5.2</option>
<option value="5.3">5.3</option>
<option value="5.4">5.4</option>
<option value="5.5">5.5</option>
<option value="5.6">5.6</option>
<option value="5.7">5.7</option>
<option value="5.8">5.8</option>
<option value="5.9">5.9</option>
<option value="6.0">6.0</option>
<option value="6.1">6.1</option>
<option value="6.2">6.2</option>
<option value="6.3">6.3</option>
<option value="6.4">6.4</option>
<option value="6.5">6.5</option>
<option value="6.6">6.6</option>
<option value="6.7">6.7</option>
<option value="6.8">6.8</option>
<option value="6.9">6.9</option>
<option value="7.0">7.0</option>
<option value="7.1">7.1</option>
<option value="7.2">7.2</option>
<option value="7.3">7.3</option>
<option value="7.4">7.4</option>
<option value="7.5">7.5</option>
<option value="7.6">7.6</option>
<option value="7.7">7.7</option>
<option value="7.8">7.8</option>
<option value="7.9">7.9</option>
<option value="8.0">8.0</option>
<option value="8.1">8.1</option>
<option value="8.2">8.2</option>
<option value="8.3">8.3</option>
<option value="8.4">8.4</option>
<option value="8.5">8.5</option>
<option value="8.6">8.6</option>
<option value="8.7">8.7</option>
<option value="8.8">8.8</option>
<option value="8.9">8.9</option>
<option value="9.0">9.0</option>
<option value="9.1">9.1</option>
<option value="9.2">9.2</option>
<option value="9.3">9.3</option>
<option value="9.4">9.4</option>
<option value="9.5">9.5</option>
<option value="9.6">9.6</option>
<option value="9.7">9.7</option>
<option value="9.8">9.8</option>
<option value="9.9">9.9</option>
<option value="10.0">10.0</option>
</select>
when i click on the objetc display all the list but if a press "5" for example the list show only "5.0", "5.1" ,"5.2" etc. and when i press 5.8 only show me "5.8" llike valu to select
So i want to select any option with VBA, (whith other combox i dont have problems but with this have error)
i have tried this
sub CALF()
Dim H As selenium.Keys
*Here find the element "select" whit the name "calAlum"* i dont have problem
For Each element In WEB3.FindElementsByTag("select")
If element.Attribute("name") = "calAlum" Then
element.AsSelect.selectbyvalue Activecell *in this part show error*
End If
Next
MsgBox "fin"
End Sub
but for this drop down doesnt work i tried to use diferent ways but dont work, NOTE: this code go to inside IF
"to focus the box but dont work"
element.click
"to write value dont work"
element.sendkeys "5.8"
"to copy value in clipboard then paste value in the objetc dont work"
WEB3.SetClipBoard ActiveCell.Value
element.SendKeys Control, "V"
but if manually select any value in the object like "9.8" and the in the code use
R= element.value
or
R=elment.attrribute("value")
return "9.8" then i use
element.asselect.selectbyvalue R work
but if i change R= "9.7" and use
element.asselect.selectbyvalue R
return Error value no found
then i tried after to wrap webelement in selectelemnet this
r= element.SelectedOption
r= element.asselect.selectedoption
to know what option is selected, but both return void "" obviusly is rare because R= element.value return "9.8" then i use
element.asselect.options
for i=0 to element.asselect.options
r(i)=element.asselect.selectedoption
next
to know all option are in selectelement "element" but return error its necesary a object so use
r = element.IsSelected
but return false thats to say i cant use the object like webelement and if i wrap to selectelment the object dont have any option, someone can help me.
If you help me how to select the object o how to manipulate object "select" dynamic
CSS selector:
You can use a CSS selector to target the option of choice and then .Click to select. You extract the option value into a variable which you concatenate into the CSS selector string.
Your example:
For your example, you can use selector select option[value='5.0'], where 5.0 is extracted into a variable.
CONST SELECTED_INDEX As String = "5.0"
WEB3.FindElementByCss("select option[value='" & SELECTED_INDEX & "']").Click
Here is an example using Facebook and selecting the drop down day for birthday.
CSS selector for Facebook birthday day:
#day option[value='18']
This reads as element with id "day", containing tag option, with attribute value that is =18. # is id selector and [] is for attribute.
VBA Code:
Option Explicit
Public Sub MakeSelection()
Dim d As WebDriver
Set d = New ChromeDriver
Const URL = "https://www.facebook.com/"
Const SELECTED_INDEX As Long = 18
With d
.Start "Chrome"
.get URL
'Selector was e.g. for day 1 "#day option[value='1']"
.FindElementByCss("#day option[value='" & SELECTED_INDEX & "']").Click
Stop '<= Delete me later
.Quit
Application.ScreenUpdating = True
End With
End Sub
Related
Im querying data which is pulled in via an Axios call. The drop-down 'subjects' pulls back results and queries the data but I would like it to only pull back exacts. For example, if I select 'English', I just want it to return subjects which have the subjects 'English' and not the subjects which are 'English and maths'.
Would I use a regEx. If so how would I go about this? Any help appreciated.
<select v-model="subject"
class="form-control"
#change="subjectonchange()"
:disabled="selectDisabledSubject"
>
<option disabled value="">Select subject</option>
<option
v-for="subject in uniquesubjects"
:key="subject"
:value="subject"
>
{{ subject }}
</option>
</select>
method: { subjectonchange: function () {
let query = "";
if (this.subject !== "") {
query = this.subject;
console.log(this.subject);
} else {
query = "!showall";
}
this.query(query);
},}
I'm Struggeling to find a solution to the following Problem:
My Razor-Page has a form with two select-elements, only one of which will be active (not disabled) at a time. Their values are associated to the same Property in my model.
I had to make my Property an Array, so I could access the value of both selects, despite one of them always being "null".
This has lead to my select being rendered with the "multiple" attribute in HTML. How can I get rid of this? I want it to be single select.
My selects:
<select asp-for=TätigkeitIds required onchange="this.form.submit()" disabled=#(Model.Erfassung.TätigkeitNavigation != null && Boolean.Equals(Model.Erfassung.TätigkeitNavigation.Abzurechnen, true))>
#{
<option selected=#(Model.Erfassung.TätigkeitNavigation == null) value="">Bitte eine nicht abzurechnende Tätigkeit wählen</option>
foreach(StammdatenTätigkeit Tätigkeit in await Model.GetTätigkeitenAsync(false))
{
<option selected="#(Model.Erfassung.TätigkeitNavigation != null && String.Equals(Tätigkeit.Id, Model.Erfassung.TätigkeitNavigation.Id))" value=#Tätigkeit.Id>#Tätigkeit.Name</option>
}
}
</select>
<select asp-for=TätigkeitIds required onchange="this.form.submit()" disabled=#(Model.Erfassung.TätigkeitNavigation != null && Boolean.Equals(Model.Erfassung.TätigkeitNavigation.Abzurechnen, false))>
#{
<option selected=#(Model.Erfassung.TätigkeitNavigation == null || Boolean.Equals(Model.Erfassung.TätigkeitNavigation.Abzurechnen, false)) value="">nicht abrech. Std.</option>
foreach(StammdatenTätigkeit Tätigkeit in await Model.GetTätigkeitenAsync(true))
{
<option selected="#(Model.Erfassung.TätigkeitNavigation != null && String.Equals(Tätigkeit.Id, Model.Erfassung.TätigkeitNavigation.Id))" value=#Tätigkeit.Id>#Tätigkeit.Name</option>
}
}
</select>
The Property:
[BindProperty(SupportsGet = false)]
public String[] TätigkeitIds { get; set; }
The rendered HTML:
<select required onchange="this.form.submit()" id="T_tigkeitIds" multiple="multiple" name="TätigkeitIds">
<option value="" selected="selected">Bitte eine nicht abzurechnende Tätigkeit wählen</option>
<option selected="selected" value="d58559ac-6601-4871-aff2-aa72982fd5cc">Schulung</option>
</select>
<select required onchange="this.form.submit()" disabled="disabled" id="T_tigkeitIds" multiple="multiple" name="TätigkeitIds">
<option selected="selected" value="">nicht abrech. Std.</option>
<option value="c2b8fd29-c85b-49c1-a2db-35b9fa9d11a0">PJ-Bearbeitung</option>
</select>
Essentially, I am looking for a way to either force the HTML-Select to appear without the multiple-attribute or to make my Property a normal String again and tell the framework to fill it with whichever input isn't null.
Based on the comment from Mike Brind, I was able to solve my problem by simply deactivating the tag helpers for my two select-Tags like so:
<!select name="TätigkeitIds" required onchange="this.form.submit()" #(Model.Erfassung.TätigkeitNavigation != null && Boolean.Equals(Model.Erfassung.TätigkeitNavigation.Abzurechnen, false) ? "disabled" : "")>
#{
<option selected=#(Model.Erfassung.TätigkeitNavigation == null || Boolean.Equals(Model.Erfassung.TätigkeitNavigation.Abzurechnen, false)) value="">nicht abrech. Std.</option>
foreach(StammdatenTätigkeit Tätigkeit in await Model.GetTätigkeitenAsync(true))
{
<option selected="#(Model.Erfassung.TätigkeitNavigation != null && String.Equals(Tätigkeit.Id, Model.Erfassung.TätigkeitNavigation.Id))" value=#Tätigkeit.Id>#Tätigkeit.Name</option>
}
}
</!select>
i would like to make default "---please make a choice--'. Actually in checkout adress form state is compilate like italia. I put a screenenter image description here
You need to find block responsible for showing province field and add something like this right above foreach loop:
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
Example based on "Select a country" located in prestashop\themes\classic\templates_partials\form-fields.tpl:
{block name='form_field_item_country'}
<select
class="form-control form-control-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}
I have two drop downs on a page. I need to verify that the item in drop down list 1 has a class of "selected" added to it when the item in drop down list 2 has been selected. Drop down list 1 has more than 3 options in it but I wanted to save space in the post. The first chunk of steps gets the values for all the items in the list and randomly selects one.
The second portion uses the value that was randomly selected in the first few steps to target the option and see check for the selected class to be true.
Here is the HTML:
<ol>
<li class="select input required" id="message_recipient_input">
<select id="message_recipient_id">
<option value></option>
<option value="1">Smith, Bob</option>
<option value="2">Smith, Steve</option>
<option value="3">Smith, Joe</option>
</select>
</li>
</ol>
<ol>
<li class="select input required" id="message_template_input">
<select id="message_template_id">
<option value></option>
<option value="9">Message Template</option>
<option value="10">Survey Template</option>
<option value="11">Coupon Template</option>
</select>
</li>
</ol>
Here are the steps in RF:
${RecipientCount}= Get Matching Xpath Count xpath=//*[#id="message_recipient_id"]/option
Log ${RecipientCount}
#{ValueList}= Create List
: FOR ${INDEX} IN RANGE 1 ${RecipientCount}
\ ${recipient_value}= Get Element Attribute xpath=//*[#id="message_recipient_id"]/option[contains(text(), '#')] [${INDEX}]#value
\ Log ${recipient_value}
\ Append To List ${ValueList} ${recipient_value}
Log ${ValueList}
${recipient}= Evaluate random.choice(${ValueList}) random
Log ${recipient}
Sleep 2s
Select From List id=message_recipient_id ${recipient}
Sleep 2s
${message_template_dropdown}= Select From List By Value id=message_template_id 9
Sleep 2s
${selected_recipient}= Get Element Attribute xpath=//option[#value=${recipient}] #selected
Log ${selected_recipient}
Should Contain ${selected_recipient} true
This works fine in Chrome and Firefox on Mac OS X but Safari isn't selecting any of the items in the lists. The steps pass as if it is selecting them but fails on the "Should Contain" step because ${selected_recipient} has None for the selected class.
I am using DataTables and I would like my length(select option) to outside of the table
(ex. on my div).
create new select form
<select name='length_change' id='length_change'>
<option value='50'>50</option>
<option value='100'>100</option>
<option value='150'>150</option>
<option value='200'>200</option>
</select>
init dataTables
var oTable = $('#example').DataTable({});
set initial value
$('#length_change').val(oTable.page.len());
add function .change
$('#length_change').change( function() {
oTable.page.len( $(this).val() ).draw();
});
reference : https://datatables.net/reference/api/page.len()
It cannot be directly moved by just copying the whole change length drop down outside the table.
Instead create a new drop-down, where ever you want but set the following in the datatable call -
<select name='length_change' id='length_change'>
<option value='50'>50</option>
<option value='100'>100</option>
<option value='150'>150</option>
<option value=''>All</option>
</select>
`var oTable = $('#sample_1').dataTable( {
.....
"bLengthChange": false, //This will disable the native datatable length change
.....
...
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "length_change", "value": $('#length_change').val() } );
},
.....
....
});
`
The `aoData.push` will send the selected value of the customer length change to the server.
In the Model Class from where the array will be returned for the datatable, include the pushed value to the limit.
i.e. if `$postData` is the array of posted values to the server then -
`if($postData['length_change'])
$limit = (int) $postData['length_change'];
else
$limit = _DEFALUT_VALUE;
`
I hope it helps.