Jump to content

Error getElementByName


Recommended Posts

This is a Simply code to login into Google account.

$username = InputBox("Message","Type Acc")
$password = InputBox("Message","Type Pass")
$oIE = ObjCreate("InternetExplorer.Application") ;
$oIE.visible = True ; show ie
$oIE.Navigate("https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.com.vn/")
Sleep(10000)
$oIE.document.getElementById("Email").value=$username ; input acc
$oIE.document.getElementByName("Passwd").value=$password ; Input pass
$oIE.document.getElementById("signIn").click ; click button Login

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Program Files\AutoIt3\googlelogin.au3"

C:\Program Files\AutoIt3\googlelogin.au3 (8) : ==> The requested action with this object has failed.:

$oIE.document.getElementByName("Passwd").value=$password

$oIE.document.getElementByName("Passwd")^ ERROR

>Exit code: 1 Time: 15.042

and $oIE.document.getElementByName("Passwd").value=$password ; Input pass

didnt work.

is this a bug ?

Please help me.

Link to comment
Share on other sites

There is no DOM method getElementByName - it is getElementsByName and it returns a collection, so you need to specify an item:

$username = InputBox("Message","Type Acc")
$password = InputBox("Message","Type Pass")
$oIE = ObjCreate("InternetExplorer.Application") ;
$oIE.visible = True ; show ie
$oIE.Navigate("[url="https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.com.vn/"]https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.com.vn/[/url]")
Sleep(10000)
$oIE.document.getElementById("Email").value=$username ; input acc
$oIE.document.getElementsByName("Passwd").Item(0).value=$password ; Input pass
$oIE.document.getElementById("signIn").click ; click button Login

Using the _IE functions from IE.au3 would likely simplify this for you.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

That's because the name of the elelment on that site is "password", not "Passwd".

I don't think you have a very good understanding of what you are trying to do. Again, the _IE function will help you with examples and error handling. Please see the helpfile.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

  • Moderators

phamhoangthi,

And also please read the Forum Rules - particularly the bit that says:

"Do not discuss any of the following:

[...]

This includes forum or site auto-login methods". :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...