cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rhawkins10701
Regular Visitor

Run JavaScript Function on web page

Wanting flow to change value of drop down box on web page. Drop down value will be 'Strength' and Field 3 is referencing which drop down box.

 

Run action but value is not changing need assistance with syntax. Any help is appreciated!

 

 

rhawkins10701_0-1631650846294.png

 

5 REPLIES 5
VJR
Resolver I
Resolver I

Hi @rhawkins10701 

 

Could you also please try with the other options like

 

document.getElementById('Field3').value = 'Strength';
document.getElementById('Field3').selectedIndex = 2;    //Starts from 0, if Strength is at the 3rd position

 

Also right click on that element and Inspect the code for the dropdown.

Also, some dropdown values are only triggered if the text is written via SendKeys




-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.

Thanks I attempted both syntax and still not triggering the dropdown value.  I am not familiar with SendKeys that you were referring to. How would I write text via SendKeys? 

 

Thanks for your assistance!

VJR
Resolver I
Resolver I

Hi @rhawkins10701 

 

Sendkeys should be the last resort when nothing else works.

 

You are using Power Automate Desktop, so curious to know why are you looking to inject javascript to change the dropdown value?

You can spy that element and perform any of the UI Automation options that PAD gives.

Set drop-down list value on web page:

https://docs.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/webautomation#setdro...

 

 

This is how the dropdown on the webpage looks like

 

VJR_0-1631851994184.png

 

This is the html of the above webpage

VJR_3-1631852223415.png

 

 

 

Changing the car value using "Set drop-down list value on web page":

VJR_1-1631852091436.png

 

 

After running the process the dropdown value is changed

VJR_2-1631852172030.png

 

 



-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.


Thanks for the assistance with the new action! I am still having issues and I am thinking it is because the web page is crystal reporting. Would this have an effect on the action? I added new UI element and selected the drop down value.

 

rhawkins10701_0-1632153835651.png

 

Also, prior to selecting the drop down value I have to click "click to select custom fields" in order to display the drop down values. I've attempted to use action Click Link on Web Page to display drop down values but wasn't working.

 

 

 

rhawkins10701_2-1632153938808.png

 

 

rhawkins10701_1-1632153879098.png

 

VJR
Resolver I
Resolver I

Hi @rhawkins10701 

 

Yes it is true that some webpages are not "spyable" due to the nature they are built.

 

- Are you able to see the html of the select dropdown just like the way I showed you

VJR_0-1632197486716.png

 

- play with the selectors and see which one behaves better than the other.

Keep ticking one or more combination of options

 

VJR_1-1632197651765.png

 

 

- I will anyways share with you the Sendkeys option too but do keep it as your last alternative

 

  • Click on that element
  • Use appropriate Wait time
  • After Sending the Down arrow it selected the second element in below screenshot
    • Here you can also send the Down arrow multiple times depending on where your 'Strength' value is in the list
    • Alternatively, you can also type the initial alphabet or the starting few characters like S (as in Strength). Take care about another word starting with the same character S).

VJR_2-1632198156648.png

 

 

- For reference Saab is the 2nd option in the list.

VJR_3-1632198423177.png






-------------------------------------------
Help fellow beings find relevant posts.
Upvote to a supporting response.
Mark as solution to an answer.

 

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,299)