Fernandin Posted October 12, 2019 Posted October 12, 2019 Hi everyone, I'm learning AutoIt Script and trying to create a script that automates the opening of incidents. There's some <input> boxes that I need to fill with a text and also some <select> lists, where I choose things like location and department. I believe that clicking on these lists and typing the item desired, I already can get what I want, without opening the list and selecting the <option> ... </option>. The thing is that all of those things that I wished to get as object, by using "_IEGetObjById" and then _IEAction($object, "click", they are inaccessible because each of them are between <span> </span>. That's what I think so... So please I need help, I there another way of getting those items as an object and then clicking or typing in them???
FrancescoDiMuro Posted October 12, 2019 Posted October 12, 2019 Hi @Fernandin, and welcome to the AutoIt forums For more assistance, could you please post your script, and if it is possible, the link to the webpage you are trying to interact with? If it is not possible, please post the source code of the webage, at least Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Fernandin Posted October 12, 2019 Author Posted October 12, 2019 Hellow @FrancescoDiMuro, unfortunately the website is in the intranet... But, anyway, there's a part of the site that's the part where I need to type somethings I've tried this $idOne = _IEGetObjById($oIE, "Spanwrapper_PrimaryUserTextBox") _IEDocInsertText($num, "123456") It didn't work so...
Fernandin Posted October 12, 2019 Author Posted October 12, 2019 I'm sorry, actually $num is $idOne, I forgot to change it...
Danp2 Posted October 12, 2019 Posted October 12, 2019 _IEDocInsertText is the wrong function for what you want to accomplish. Try this -- $oInput = _IEGetObjByName($oIE, "PrimaryUserTextbox") _IEFormElementSetValue($oInput, "123456") Latest Webdriver UDF Release Webdriver Wiki FAQs
Fernandin Posted October 14, 2019 Author Posted October 14, 2019 @Danp2 Thanks for the answer! I''ve tried but it didn't work... I only got an error message: ?_IEFormElementSetValue($oInput, "123456") ^ ERROR
FrancescoDiMuro Posted October 14, 2019 Posted October 14, 2019 @Fernandin There's a special character at the start of the line you copy-pasted; edit it with Notepad++ (or any other editor where you can see special characters) Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Fernandin Posted October 14, 2019 Author Posted October 14, 2019 @FrancescoDiMuro Fine, I got what you can see in the image below. If it isn't working, what else can I do?? I wish I could take the textbox as an object and then insert some typed data...
Musashi Posted October 14, 2019 Posted October 14, 2019 @Fernandin The first 3 characters indicate that the text is encoded as UTF8 with BOM (Byte Order Mark) --> Hex : EF BB BF "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Fernandin Posted October 14, 2019 Author Posted October 14, 2019 (edited) So is this the reason of not getting the textbox by id as an object? Edited October 14, 2019 by Fernandin
Musashi Posted October 14, 2019 Posted October 14, 2019 10 minutes ago, Fernandin said: So is this the reason of not getting the textbox by id as an object? Not necessarily. The command _IEFormElementSetValue itself becomes invalid due to the preceding coding. Type the command in your editor by hand (not by Copy & Paste). "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Fernandin Posted October 14, 2019 Author Posted October 14, 2019 Fine, I typed the line on my own and then I got this: --> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: PrimaryUserTextbox, Index: 0) --> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType Isn't the object inaccessible by id and/name because of the <span>?
Danp2 Posted October 15, 2019 Posted October 15, 2019 Ok... how about this? $oSpan = _IEGetObjById($oIE, "Spanwrapper_PrimaryUserTextBox") $oInput = _IEGetObjByName($oSpan, "PrimaryUserTextbox") _IEFormElementSetValue($oInput, "123456") Latest Webdriver UDF Release Webdriver Wiki FAQs
Fernandin Posted October 15, 2019 Author Posted October 15, 2019 Nothing yert... --> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (Spanwrapper_PrimaryUserTextBox) --> IE.au3 T3.0-2 Error from function _IEGetObjByName, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-2 Error from function _IEFormElementSetValue, $_IESTATUS_InvalidDataType There's a print screen of the table with the textbox where I pretend to type
Danp2 Posted October 15, 2019 Posted October 15, 2019 24 minutes ago, Fernandin said: --> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (Spanwrapper_PrimaryUserTextBox) This is telling you that the span wasn't found. So now your job is to determine why. You previously posted code where you used an ID of "Spanwrapper_PrimaryUserTextBox". This doesn't exactly match the HTML that you posted (the case is different). Try fixing that and then report back. P.S. Have you checked to see if the website used frames? Latest Webdriver UDF Release Webdriver Wiki FAQs
Fernandin Posted October 15, 2019 Author Posted October 15, 2019 I've tried those two id that I posted... And talking about frames... I realized that there's a frame that corresponds to the whole window in wich I need to insert things... How do I deal with that?
Danp2 Posted October 15, 2019 Posted October 15, 2019 There are functions to handle frames. Look up _IEFrameGetObjByName in the help file. Latest Webdriver UDF Release Webdriver Wiki FAQs
Fernandin Posted October 17, 2019 Author Posted October 17, 2019 Finally, it worked! $frame = _IEFrameGetObjByName($page, "win_DivLoadIFrame_content") ;I just used this to take the window's frame as an object $textbox = _IEGetObjById($frame, "PrimaryUserTextbox") ;And then this, taking the textbox inside the frame Thank you guys for the support.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now