2

I am trying to write a string into an <input> element using Selenium web driver and Python in Windows.

The element it's located and selected, but the webdriver fails when trying to send_keys("mystring").

campotx = driver.find_element_by_css_selector("input.urEdf2TxtRadius.urEdf2TxtEnbl.urEdfVAlign")
campotx.click()
campotx.clear() 
##########----it works ok until here
campotx.send_keys("SM37")
campotx.send_keys(Keys.ENTER)

The issue is not related to the "find element" method: I tried by_ID, by_class_name and by_xpath. All of them are able to locate the element. I am only not able to send_keys.

I am using HTMLUNITS, the headless webdriver. The output error for this issue is rare, I tried googleing it but can't find anything:

selenium.common.exceptions.WebDriverException: Message: TypeError: Cannot call method "setOpenerRef" of null (http://myurl.com)

Here is the <input> source code:

<input id="ToolbarOkCode" ct="I" lsdata="{0:'ToolbarOkCode',1:'Command',4:200,13:'150px',23:true}" lsevents="{Change:[{ClientAction:'none'},{type:'TOOLBARINPUTFIELD'}],Enter:[{ClientAction:'submit',PrepareScript:'return\x20its.XControlSubmit\x28\x29\x3b',ResponseData:'delta',TransportMethod:'partial'},{Submit:'X',type:'TOOLBARINPUTFIELD'}]}" type="text" maxlength="200" tabindex="0" ti="0" title="Command" class="urEdf2TxtRadius urEdf2TxtEnbl urEdfVAlign" value="" autocomplete="on" autocorrect="off" name="ToolbarOkCode" style="width:150px;"/>

EDIT:

  • Tried to use PhantomJS but I was not able to logon.
  • Tried to use headless_ie_selenium.exe but I couldn't even start the driver.
  • Tried to use the headless chrome, same issue than headless_ie_selenium.All the tutorials are related to Linux environments.
4
  • 2
    Can you share the relevant page or HTML code? Commented Aug 6, 2017 at 18:21
  • 1
    Instead of HTMLUNITS, try using PhantomJS, or Chrome headless, or docker chrome standalone Commented Aug 6, 2017 at 19:15
  • Maximilian, I have updated the question. The complete sourcecode is too extensive even for pastebin. Tarun, I tried phantomjs but couldn't pass through login form. Commented Aug 6, 2017 at 21:54
  • Can you post the website link? Commented Aug 7, 2017 at 23:23

1 Answer 1

1

I finally solved this by using javascript instead Selenium send_keys.

driver.execute_script("document.getElementById('ToolbarOkCode').setAttribute('value', 'SM37')")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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