0

I want to do an automation of the Internet Explorer. Open the Internet Explorer, navigate to login.live.com and set a value into the email textbox.

Here's the simple script:

import win32com.client
import time

IE = win32com.client.DispatchEx("InternetExplorer.Application")
IE.Visible = 1
IE.Navigate('login.live.com')

time.sleep(5)

DOC = IE.document
DOC.getElementById('i0116').value = 'test'

The last line always returns the following TypeError:

getElementById() takes exactly 1 argument (2 given)

When I try to add the value through the console of the Internet Explorer it works.

Btw. the getElementsByTagName() method works without any Errors.

Thanks for any help!

Marc Egolf
  • 11
  • 3

2 Answers2

1

Okay.. I wrote a workaround for this:

DOC = IE.Document
inputs = DOC.documentElement.getElementsByTagName('input')

for field in inputs:
    if field.id == 'i0116':
        email = field
        break
email.value = 'example@test.com'

For browser automation I recommend to use the Selenium library.

Marc Egolf
  • 11
  • 3
0

As this answer suggests you have to use

DOC.Body.getElementById('i0116').value = 'test'
Community
  • 1
  • 1
Laurens Koppenol
  • 2,946
  • 2
  • 20
  • 33