VBA: Value change on a dropdown in IE doesn't update report - vba

I'm automating the download of a report. There is a dropdown for status that needs changing to the value "Started". I've managed to change the value in my code but when you manually make the change the report screen for the site updates automatically. My code doesn't manage to do this.
I'm wondering if there's an extra element that might need changing. Does anyone have any idea what I'm missing?
element on the site:
<select data-bind="value: leads.overall_status, options: [null, 'not_started', 'quoted_with_quotes', 'quoted_without_quotes', 'started', 'open_accounts'], optionsText: BrokerLeadsGridModel.overall_status_renderer" style="width: 160px;vertical-align: baseline;display: inline;" class="form-control">
<option value="">Any</option>
<option value="not_started">Not Started</option>
<option value="quoted_with_quotes">Quoted</option>
<option value="quoted_without_quotes">No Quotes</option>
<option value="started">Started</option>
<option value="open_accounts">Open</option>
</select>
My Code:
Doc.getElementsByClassName("form-control")(0).Value = "started"

Did you try attribute = value css selector?
doc.querySelector("[value=started]").selected = True

Related

How to make materializecss dropdown appear below selectbox?

I am using materilizecss and i have the following dropdown:
<select class="txtInput" data-val="true" data-val-number="The field SelectedAssetCategoryId must be a number." data-val-required="Select a asset category" id="ddlAssetCategory" name="SelectedAssetCategoryId"><option value="">Asset Category</option>
<option value="1">Disease State/Condition Training</option>
<option value="5">Hot Topics Training</option>
<option value="6">Launch Training</option>
<option value="7">Medical Meetings</option>
<option value="2">Product Training</option>
<option value="8">Quiz</option>
<option value="4">Real World Evidence/HEOR Training</option>
<option value="3">Treatment/Competitive Landscape Training</option>
</select>
I was initilizing it like so:
$("select").not('[multiple="multiple"]').formSelect({
});
But what i wanted was the dropdown to show below the selectbox not above , so i added the below line of code:
$("select").not('[multiple="multiple"]').formSelect({
belowOrigin: true
});
But even this does't seem to work , What option can i add so that the dropdown menu shows below the select box ?
Use This :
$("select").not('[multiple="multiple"]').formSelect({
dropdownOptions: {coverTrigger: false}
});
Instead of :
$("select").not('[multiple="multiple"]').formSelect({
belowOrigin: true
});
JSFiddle
Actually with dropdownOptions you can pass dropdown options to select form.

VBA IE11 locking in a change to a dropdown value

I'm using VBA to open a website, login, and navigate to a certain page. There is a dropdown with 8 options.
I used this code to change the dropdown to the value I want, but it always reverts back to the default as I continue. How do I lock this change in?
Set Element = IE.Document.getElementsByName("date_range")
Element.Item(0).Value = "custom"
Here's the page code:
<div class="SelectInput">
<select class="SelectInput-select" name="date_range">
<option value="all_time">All Time</option>
<option value="today">Today</option>
<option value="yesterday">Yesterday</option>
<option value="this_month">Month to date</option>
<option value="last_month">Last Month</option>
<option value="this_year">Year to date</option>
<option value="last_year">Last year</option>
<option value="custom">Between...</option>
</select>
<div class="SelectInput-arrows">...</div>
</div>
Thanks,
you need to set the selected attribute .... ref: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_selected

tooltipster jQuery plugin not working if not div

I'm trying to use tooltipster jQuery plugin, but it doesn't work for or tag :
I've just tried this simple code :
<div id="my-tooltip">
This div has a tooltip with HTML when you hover over it!
</div>
--> div works fine
<select id="my-tooltip" name="select">
<option value="value1">Valeur 1</option>
<option value="value2" selected>Valeur 2</option>
<option value="value3">Valeur 3</option>
</select>
--> select doesn't work
<span id="my-tooltip">
test with span
</span>
--> span doesn't work
Could you please help me ?
here is my page
thank you all !
From looking at your code and site the issue is due to your multiple use of the id my-tooltip. IDs should only be used once to identify one node. A simple test can be done to prove this using jQuery, try running this on the page:
jQuery('#my-tooltip')
You'll see that only one node is returned, this is the one that has your initialised tooltip.
To fix this you'll need to change your nodes to use classes, i.e.
<div class="my-tooltip">
This div has a tooltip with HTML when you hover over it!
</div>
<select class="my-tooltip" name="select">
<option value="value1">Valeur 1</option>
<option value="value2" selected>Valeur 2</option>
<option value="value3">Valeur 3</option>
</select>
<span class="my-tooltip">test with span</span>
In your tooltipster setup, you'll want to have the following selector and options enabled:
jQuery('.my-tooltip').tooltipster({
// Original setup
content: jQuery('<span><img src="/../../../popup.png" /> <strong>This text is in bold case !</strong></span>')
// Additional options
multiple: true,
contentAsHTML: true
});
I hope this helps! :)

Back button causes dropdown to have different values

I have an ASP.Net MVC app, and when a user clicks a certain link, I do the following:
var orderID = returnStatus["Data"];
var url = '#Url.Content("~/OrderEntry/OrderDetail")?orderID=' + orderID;
window.location.href = url;
This works great, however, when I click the back button, my html dropdown changes from:
Zone: <select id="Zones" name="Zones" style="width: 150px"><option value="1">Zone 1</option>
<option value="2">Zone 2</option>
<option value="3">Zone 3</option>
<option value="4">Zone 4</option>
</select>
to this:
Zone: <select id="Zones" name="Zones" style="width: 150px"><option value="QUOTE">Quote</option>
<option value="SUBM">Submitted</option>
<option value="INPRD">In Production</option>
<option value="CANC">Cancelled</option>
<option value="COM">Complete</option>
<option value="CH">Credit Hold</option>
</select>
These statuses are defined in a dropdown later in the code, and I'm not sure why they have moved up to this dropdown?
Both of these dropdowns are populated from the model. It's almost as if the model is trying to re-generate this html, but the values are somehow incorrect?
Here is the Razor syntax:
Zone: #Html.DropDownList("Zones", Model.Zones, new { style = "width: 150px" } )
This doesn't appear to happen in Firefox or Chrome.
Apparently it had to do with the fact that my ID was called "Zones". I changed this ID to AcctManagerZones and everything is working fine now.
Edited: It appears this wasn't exactly the answer either. It apparently has to do with the way IE caches the page. I still got the same thing, until I turned page caching off, then it worked.

How to get displayed text from disable dropdown list?

how can i get visible value from disable dropdown list ?
Best Regards,
thank you
You can use selenium.getSelectedValue() or selenium.getSelectedLabel(). Both are described here.
If you have a dropdown list defined as follows:
<select name="dropdown" disabled>
<option value="1">one</option>
<option value="2">two</option>
<option selected value="3">three</option>
<option value="4">four</option>
</select>
Then you can use the following script to assert that the (disabled) selected label is 'three'.
String selectedLabel = selenium.getSelectedValue("name=dropdown");
assertEquals("three", selectedLabel);