I'm hoping someone might be able to point me in the right direction here. I'm trying to use selenium to automate entering details for media files after they've been uploaded to a website. I'm able to navigate to the media library and parse the list for the files in question, but I'm hung up on how to send input to the fields.
It looks like the website was built with React Material UI, and I'm having to use xpath exclusively, which is actually working pretty well. I'm able to get to the media details page, but that's where I've hit the wall.
Here's the exact html for the input field I'm trying to interact with and what the page looks like.
<div class="MuiFormControl-root MuiFormControl-marginNormal MuiFormControl-fullWidth">
<label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink" data-shrink="true" for="formatted-text-mask-input">Subtitle</label>
<div class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-formControl MuiInput-formControl" title="Subtitle">
<input aria-invalid="false" type="text" class="MuiInputBase-input MuiInput-input" value="" data-np-intersection-state="visible">
</div>
<p class="MuiFormHelperText-root"></p>
</div>
</div>
I've tried to get the input field by xpath and css selector using:
driver.find_element(By.XPATH('//*[@id="app"]/div/div/div[2]/div/div/div[4]/div/div[2]/div[1]/div[3]/div/div/input'))
But this gets the text property not the element and throws a TypeError. I read values can't be set directly with selenium because it's meant to simulate user input.
Can this need to be done with
webdriver.execute_script("set_attribute(arguments?)")
? If so, how do I pass my text using execute_script
?
Or is there some other browser automation that would work with React/Material UI websites?
Thanks!