Powershell - IE11 - Apex - Automated Dropdown Selection - oracle

I am trying to automate some tasks for an existing website written using Oracle Apex via PowerShell. There is a dropdown for States and when a state is selected the data needs to change accordingly. I am able to select the desired state and fire the "OnChange" Event successfully but it does not change the data like a Manual Selection of the Dropdown option would. Could someone please assist how I can using PowerShell get the same result as a Manual Selection.
Here is the sample of the Dropdown box.
<select id="All_STATE" name="All_STATE" class="selectlist apex-item-select" size="1" >
<option value="" selected="selected" >- Please Select -</option>
<option value="Texas">Texas</option>
<option value="Kansas">Kansas</option>
<option value="Michigan">Michigan</option>
</select>
Here is powershell code I am trying to use
$statecontrol = $null
$statecontrol = $ie.document.IHTMLDocument3_getElementById("All_STATE")
($statecontrol | where {$_.value -eq "Texas"}).Selected = $true
$statecontrol.FireEvent("OnChange")
I found these functions under JavaScript which may be relevant but can't be sure, I don't know APEX. I don't think I can share the whole JavaScript here cause its proprietary.
function(){ apex.widget.selectList("#All_STATE",{`code here`});})();
function(){ apex.jQuery('#List').interactiveReport.interactiveReport({`code here`});})();
{"triggeringElementType":"ITEM","triggeringElement":"All_STATE","bindType":"bind","bindEventType":"change","anyActionsFireOnInit":false,actionList:`code here`

Based on your description, I created a simple example to achieve your requirements, and I think your issue is mainly the loading situation of the automated page, a similar case.
This is my test, and it works well:
Page code:
<select id="All_STATE" name="All_STATE" class="selectlist apex-item-select" size="1" onchange="myFunction()">
<option value="" selected="selected">- Please Select -</option>
<option value="Texas">Texas</option>
<option value="Kansas">Kansas</option>
<option value="Michigan">Michigan</option>
</select>
<script>
function myFunction() {
alert('some script code here');
}
</script>
powershell code:
$ie = New-Object -ComObject internetexplorer.application
$ie.Visible = $true
$ie.Navigate("<your website url>")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$statecontrol = $ie.document.IHTMLDocument3_getElementById("All_STATE")
($statecontrol | where {$_.value -eq "Texas"}).Selected = $true
$statecontrol.FireEvent("OnChange")
Result:

Related

How to check disabled item in a <select>

Im trying to write a test that should check if an item in a is disabled.
The item is visible, but not clickable, and that's correct. But Im not sure how to write my test to make it pass this as correct.
My current test will fail due to not being able to select 'Create new'.
it('Not clickable', function() {
cy.visit(url);
cy.get('#dropDownMenu').should('be.visible', 'Choose...');
cy.get('#dropDownMenu').select('Create new').should('be.disabled');
})
How can I make my test find and understand that my select('Create new') should be disabled and that this is correct?
Here is the dropdownmenu html:
<select name="#dropDownMenu" id="dropDownMenu"
data-ng-change="$ctrl.onSelectdropDownMenu()"
data-ng-model="$ctrl.handleDropDownMenuOptions.val"
class="ng-pristine ng-valid ng-not-empty ng-touched">
<option data-ng-repeat="option in
$ctrl.handleDropDownMenuOptions.availableOptions"
data-ng-disabled="option.disabled"
value="NOT_SELECTED" disabled="disabled">Choose...</option>
<option data-ng-repeat="option in
$ctrl.handleDropDownMenuOptions.availableOptions" data-ng-
disabled="option.disabled" value="NEW" disabled="disabled">Create
new</option>
This solved it:
cy.get('#dropDownMenu').get('[value="NEW"]').should('be.disabled');

Laravel old for selectbox options

So i'm working on a standalone laravel project (still a bit new to this..). Using the same form blade file adding and editing records. I've set old to the fields for validation checks, however i can't seem to get old working correctly for dropdowns. The select options are loaded in a foreach, and ive got a check to set it to selected if the record on edit matches the dropdown option selected, however when i add the old method to it, select a new option (E.G. "broker") and force validation to throw an error it works as expected & saves whatever i've selected (option "broker"), it saves the option on submit, but then when i go to edit another record (option "assessor") it displays the same option i previously selected (option "broker")...if any of that made sense!
Here's the foreach with option select from the blade file:
<select class="form-control" name="other_party_details[party_type_id]" id="other_party_details[party_type_id]">
<option value="">--- Please Select ---</option>
#foreach($partyTypes as $partyType)
<option value="{{ $partyType->id }}" {{old('other_party_details.party_type_id', !empty($claim->otherParty->party_type_id)) == $partyType->id ? 'selected' : '' }}>
{{ $partyType->label }}
</option>
#endforeach
</select>
What am i doing wrong?
I've exhausted google as for the most it seems to show results for multi select (mine is not), or using LaravelCollective (which i'm not), so running out of places to look!
Thanks in advance
You can try below code
<option value="{{$partyType->id}}" #if(old('party_type_id') == $partyType->id || $claim->otherParty->party_type_id == $partyType->id ) selected #endif> {{ $partyType->label }}</option>

Laravel VUE JS dynamic drop down menu

Why doesn't this work?
Here is my select tag:
<select class="form-control" v-model="provider">
<option value="0">Select Provider</option>
<option v-for="provider in providers" :value="provider.provider_id">{{provider.name}}</option>
</select>
Code which loads the data:
loadProviders(){
axios.get('api/provider').then(({data}) => (this.providers = data.data));
data is then stored in:
data(){
return{
providers : {}
}
}
I've checked the developer networks tab of Chrome and it does return the data from the database.
However the value(provider.name) doesnt show up in the dropdown options menu.
This issue has already been solved: the model for Provider had an error all along.
The issue is, that you are destructuring the API response, but don't take into account that when assigning to data.
axios.get('api/provider').then((data) => (this.providers = data.data));
and
axios.get('api/provider').then(({data}) => (this.providers = data));
both work.
Update your select box
<select v-model="provider">
<option v-for="(value,key) in provider"
:value="value.provider_id">
{{value.name}}
</option>
</select>
Make sure you received proper data from your API.
assign data to provider variable. it will appeare in select box

web2py how to: Ajax to send dropdown menu's value to action

I have a working dropdown menu, and I can send its value to a function using "submit" button. It's quite clumsy however, as user always has to press the button, wait for the page to load and it refreshes the page so the user loses all other "settings" made on the page. I have understood that ajax would be the solution for this. I read the guide: http://www.web2py.com/books/default/chapter/29/11/jquery-and-ajax#The-ajax-function and tried a few methods, but it never works.
So this is my original working code. Some contents are stripped and altered, but the basics are the same. View demo.html:
<form action="change_dropdown">
<select name="tables">
<option value="first_value">first</option>
<option value="second_value">second</option>
<option value="third_value">third</option>
</select>
<br><br>
<input type="submit">
</form>
Action:
def change_dropdown():
if request.vars.tables:
session.tables = request.vars.tables
else:
session.tables = None
session.main_warning= "Incorrect parameters for function: 'change_dropdown()'."
redirect(URL('demo'))
return
Then the original action demo does something with session.tables and so on. But now about turning it to ajax. This is what I want:
<form>
<select name="tables", onchange="ajax('change_dropdown', [], '');">
<option value="first_value">first</option>
<option value="second_value">second</option>
<option value="third_value">third</option>
</select>
</form>
I also did this to the action: redirect(URL('demo'), client_side=True) as mentioned in an example. I have no idea why it's needed however.
But I don't know how to send the variable tables to the action. If I write it inside python URL helper, it crashes, because it thinks it's a python variable (where it's actually a JavaScript variable (?)). If I write it inside ajax() function's second parameter, it halts and gives me a weird error in JS console:
Uncaught Error: Syntax error, unrecognized expression: [name=[object HTMLSelectElement]]
If you need more information I can show you full codes for the methods I tried, but I think someone can take it from here.
You can send the variable as follows:
ajax("{{=URL('change_dropdown')}}",['tables'],':eval')
redirect(URL('demo'), client_side=True) is needed as you want to redirect the function that have sent the ajax request to redirect not 'change_dropdown' to redirect.
EDIT:
<form>
<select name="tables", onchange="ajax(\"{{=URL('change_dropdown')}}\",['tables'],':eval') ;">
<option value="first_value">first</option>
<option value="second_value">second</option>
<option value="third_value">third</option>
</select>
</form>

ajax code for jsp

How to write Ajax code to retrieve information on to a particular part of webpage when we select option from a dropdown box?
I want information of a particular item that I had selected from a dropdown menu on particular part of my webpage.
Let's say your markup looks something like:
<select id="dropdown">
<option value="1">Some option</option>
<option value="2">Other option</option>
<option value="3">Helpfull option</option>
<option value="4">Don't pick this option</option>
</select>
<div id="details"></div>
In order to make AJAX calls I would use some sort of library. Using for instance jQuery will be much easier than writing code that handles ajax calls across different browsers. The code could look like this:
$('#dropdown').on('change', function(e) {
var currentValue = $('#dropdown').val();
$.get('<someurl>', function(data) {
$('#details').html(data);
});
};
Replace '<someurl>' with the url to the resource you want. Doing this without using jQuery or similar library is a bit more involved. For some guidance you can look at this answer: https://stackoverflow.com/a/2557268/355499

Resources