internet explorer - Manipulating javascript dropdown with powershell -


so, started playing powershell today, , i've been searching, can't find answer. i'm not sure if i'm looking in right place.

i need use powershell select right combination in dropdowns. 1 dropdown list of companies , other list of services. services list populated depending on company selection.

using ie comobject:

$company = $doc.getelementbyid("id_companyselection") $service = $doc.getelementbyid("id_companyservice")  foreach ($item in $company) {   if ($item.text -eq "name_of_company") {     $shippingmethod.value = $item.value   } } 

is there way force javascript register onchange event? default "service" dropdown, can't match text have value need select. there way use existing value -> text mapping?

i ran @ last job, , never found great solution. problem when change .value you're doing on dom, you've found javascript doesn't notice change.

the extremely hacky way found work send keys element. don't have code in front of me can't tell exact syntax. works because javascript sees same if input came keyboard buffer, , update accordingly.

this wouldn't bad if not following downside: ie page has visible , active send keys work - can't send keys com object. make com object visible, select process, can send keys window. quite brittle , makes user can't multi-task while script runs. hope else has more elegant method. :)

for example of drop-down rather text field, you'd have select field , send down arrays move different values of drop-down.


Comments