1

Background
I am trying to automate a website data input; however, I have not found a way to send the value to the field "___33_xsde_6h_input__data" for the portion of the HTML attached.
I have seen that Selenium is unable to write directly to hidden fields per the question 1, the question 2, question 3 and question 4. However I have not been able to find the specific solution for my scenario.
Code Attempted
HTML

<td class="RND_Input" colspan="1"><div id="RND_generatedId_1" class="RND_FieldDecor">
<div class="RND_MII_Container">
<input type="hidden" name="___33_xsde_6h_input__data" value="RND:null-axxx"><input id="___33_xsde_6h_input__data" class="" type="text" 
value="[not defined]" autocomplete="off">
</div></div></td>


Python:
I have tried most of the solutions to see if the element is being able to be set, without luck

#Attempt 1 by Xpath
inputElement =ObjSelenium.find_element(By.XPATH,'//*[@id="___33_xsde_6h_input__data"]')
inputElement =ObjSelenium.find_element(By.XPATH,'.//input[@id="___33_xsde_6h_input__data"]'
    '/following-sibling::input[@type="hidden"]')
#Attempt 2 by CSS_SELECTOR 
inputElement=ObjSelenium.find_element(By.CSS_SELECTOR,'div.RND_Input>input[type=hidden]') 
inputElement=ObjSelenium.find_element(By.CSS_SELECTOR,'div.RND_MII_Container>input[type=hidden]')
#Attempt 3 by ID
js = "document.getElementById('___33_xsde_6h_input__data').value = 'text';"
ObjSelenium.execute_script(js)


Question
How can I be able to set the HTML element ""___33_xsde_6h_input__data"" within Selenium driver in order to update its value?

Edit: The answer from Undetectable Selenium threw the following (with both approaches)

TimeoutException: Message: 
Stacktrace:
Backtrace:
    Ordinal0 [0x0039FDC3+2555331]
    Ordinal0 [0x003377F1+2127857]
    Ordinal0 [0x00232E08+1060360]
    Ordinal0 [0x0025E49E+1238174]
    Ordinal0 [0x0025E69B+1238683]
    Ordinal0 [0x00289252+1413714]
    Ordinal0 [0x00277B54+1342292]
    Ordinal0 [0x002875FA+1406458]
    Ordinal0 [0x00277976+1341814]
    Ordinal0 [0x002536B6+1193654]
    Ordinal0 [0x00254546+1197382]
    GetHandleVerifier [0x00539622+1619522]
    GetHandleVerifier [0x005E882C+2336844]
    GetHandleVerifier [0x004323E1+541697]
    GetHandleVerifier [0x00431443+537699]
    Ordinal0 [0x0033D18E+2150798]
    Ordinal0 [0x00341518+2168088]
    Ordinal0 [0x00341660+2168416]
    Ordinal0 [0x0034B330+2208560]
    BaseThreadInitThunk [0x76026359+25]
    RtlGetAppContainerNamedObjectPath [0x77B087A4+228]
    RtlGetAppContainerNamedObjectPath [0x77B08774+180]
2
  • 1
    HTML is incomplete. It still needs a </div> Commented Jan 13, 2022 at 19:51
  • 1
    @undetectedSelenium Thank you, I assumed it was one of the leftovers but I just realized my error Commented Jan 13, 2022 at 19:52

2 Answers 2

1

Solution:
The thing is that the code was in another frame, I realized it when I tried to update my HTML and realized there were 2 body tags.

So in order to activate the correct Xpath, I needed to activate the frame per this question

ObjSelenium.switch_to.frame(ObjSelenium.find_element(By.XPATH,"//iframe[@name='RND _SubSessioniFrame']")) 
#where RND_SubSessioniFrame is the name of the iframe element associated in the main HTML
inputElement =ObjSelenium.find_element(By.XPATH, '//*[@id="___33_xsde_6h_input__data"]')
inputElement.send_keys("Yay!")

As noticed, I do not set Wait elements here because I did so before going to the previous step with the following.

WebDriverWait(ObjSelenium, 10).until(ObjSeleniumExpectedConditions.presence_of_element_located((By.XPATH, '//*[@id="ButtonShowedAfterLoad"]'))) 
Sign up to request clarification or add additional context in comments.

Comments

0

To send a character sequence to the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "td.RND_Input input[id*='input'][id$='data']"))).send_keys("Sgdva")
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//td[@class='RND_Input']//input[contains(@id, 'input') and contains(@id, 'data')]"))).send_keys("Sgdva")
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

1 Comment

Thank you! However I am running into issues using both methods, my question is updated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.