Jump to content

Reading a string value that is visible within DevTools > Elements > Properties > "value"


Go to solution Solved by Danp2,

Recommended Posts

Good morning, everyone, 

I am using WebDriver with ChromeDriver version 105.0.5195.52

I have the script almost completed; this is going to be used as a wait / pause until the file has completed uploading. I was able to find where the value: "C:\\fakepath\\Vladimir Harkonnen.jpg" is stored. I am trying to figure out how to read this value. This is part of an <input type="file"> element. Reading / finding the value would be the trigger to allow the script to continue. I don't know very much but I feel like I am either not using WebDriver correctly or possibly it won't be able to help me with what I am trying to do.

Please see the attached screenshot. 

Thank you for your time, experience, and patience with me,




Thomas Bennett

 

How do I find this value.png

Link to comment
Share on other sites

40 minutes ago, Danp2 said:

It looks like the filenames are located in the Files property, so you would use _WD_ElementAction to access them, ie --

$sFiles = _WD_ElementAction($sSession, $sElement, 'property', 'files')

 

Thank you, @Danp2! I hope that you didn't take my comment despairingly against your work; if you did I apologize as that was not my intent. Thank you for thinking ahead and having this feature already built-in. I am still using 'value' since the script is waiting for that value to change from null to the path described above.

Again, thank you for your time on this,




Thomas Bennett

Edited by ThomasBennett
Forgot the closing line and signature.
Link to comment
Share on other sites

@ThomasBennettYou didn't say anything disparaging, so please stop apologizing. I will let you know if you say something offensive. I hope you would do the same for me. 😉

Browser automation via Webdriver is a complex subject, and there are usually multiple ways to tackle a given task. Just remember that "value" won't necessarily reflect if there are multiple files selected for upload.

Link to comment
Share on other sites

@Danp2, makes sense; fortunately in this case the webpage in question will only accept one file per entry. Also, a process that typically takes ~40 minutes and lots of focus is now down to approximately 6 minutes. Have you attempted to calculate how much time the Webdriver has saved the world compared to the amount of time it took to develop it? Case in point; took me ~14 hours of research and coding to get this figured out.. and looking at my work queue this script will pay for itself after I've ran it ~17 more times. 

Thank you again!




Thomas Bennett

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...