RichardL Posted January 16, 2011 Share Posted January 16, 2011 Hello, I want to set the values in 3 DropDownBoxes on a web-page. Html for 1st box is: <select class="standardFont quickTransferDropDownSelect" id="ctl00_MainPageContent_char1_DropDownList" name="ctl00$MainPageContent$char1$DropDownList"> <option value="-1" selected="selected"> Please select </option> <option value="4"> a </option> <option value="5"> b </option> ... I'm working on web-page SavedAs local file so not to cause lots of failed logins before I get it right. I tried: _FFSetValue: For $chix = 1 To 3 $ans = 4 $id = StringFormat("ctl00_MainPageContent_char%1d_DropDownList", $chix) _FFSetValue($ans, $id, "id") The console window shows __FFSend: try{window.content.top.document.getElementById('ctl00_MainPageContent_char1_DropDownList').value='i'}catch(e){'_FFCmd_Err';}; __FFRecv: i So that's alright? but no visible change on web-page or in html viewed with FireBug. I tried sending _FFClick, and then down-arrows, but nothing to the DropDown, and he web-page moves down. _FFClick ($id, "id", 0, 0) send("{Down}") __FFSend: try{FFau3.simulateEvent(FFau3.WCD.getElementById('ctl00_MainPageContent_char1_DropDownList'),'MouseEvents','click');}catch(e){'_FFCmd_Err';}; __FFRecv: 1 I tried getting the whole page html, modify, write back: $html = _FFReadHTML("body") $html = StringReplace($html,"Help","Hello World") $html = StringReplace($html,"-1","3") _FFWriteHTML($html) Again, __FFRecv: 1, and no error messages, but nothing changes on the page. Any suggestions appreciated. Richard. Link to comment Share on other sites More sharing options...
Stilgar Posted January 16, 2011 Share Posted January 16, 2011 (edited) Hello, if you wanna change the value of one of the options, you can try this: $sOption1 = _FFXPath("//select[id='ctl00_MainPageContent_char1_DropDownList']//option[1]","",9) ; first option _FFObj($sOption1, "value", "1") or want you select one option? Then look at this: http://english.documentation.ff-au3.thorsten-willert.de/ff_functions/_FFFormOptionselect.php Stilgar Edited January 16, 2011 by Stilgar jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
RichardL Posted January 16, 2011 Author Share Posted January 16, 2011 "select one option" - yes, and using your link have it working now with this: $ans = "3" _FFFormOptionselect($id, "id", $ans, "text") Thanks, Richard Link to comment Share on other sites More sharing options...
RichardL Posted January 16, 2011 Author Share Posted January 16, 2011 Well, I said it worked, and it does for most values. For the numbers 0..9 it works, accepts number or string. For the letters a..z most work but some don't. I made the prog send 0..9,a..z and the ones that fail are a,c,e,l,s,t. When it fails the DropDownBox shows "Please Select". For each setting the console has the same 3 lines, for fail or not, shown for 9,a,b. I tried various other things, sending "A" - nomatch. Reverse the order of sending - same ones fail. Manually pull down each value - all normal. All the other options for $sOptionMode (but sending the value) - all fail. All 3 Boxes - the same. The html for the DropDownBox shows the options in a very peculiar order, maybe there's an alpha-sort implied somewhere. I've included the whole html for it below. I can't see any link between the order and the ones that fail. e.g. the options for k,l,m are in order with values 14,15,16, and l fails. Richard. For $anix = 0 to 9 + 26 $chix = 1 $id = StringFormat("ctl00_MainPageContent_char%1d_DropDownList", $chix) if $anix <= 9 then $ans = $anix Else $ans = chr(asc("a") -1 + $anix - 9) EndIf ConsoleWrite(StringFormat("D1 -%s- \n", $ans)) _FFFormOptionselect($id, "id", $ans, "text") Sleep(800) Next Console: ... D1 -9- __FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form[1]//select[@id='ctl00_MainPageContent_char1_DropDownList']//option[contains(.,'9')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.selected=true;}catch(e){'_FFXPath_Error: '+e;}; __FFRecv: 1 D1 -a- __FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form[1]//select[@id='ctl00_MainPageContent_char1_DropDownList']//option[contains(.,'a')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.selected=true;}catch(e){'_FFXPath_Error: '+e;}; __FFRecv: 1 D1 -b- __FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form[1]//select[@id='ctl00_MainPageContent_char1_DropDownList']//option[contains(.,'b')]",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.selected=true;}catch(e){'_FFXPath_Error: '+e;}; __FFRecv: 1 ... DropDownBox html: expandcollapse popup <select class="standardFont quickTransferDropDownSelect" id="ctl00_MainPageContent_char1_DropDownList" name="ctl00$MainPageContent$char1$DropDownList"> <option value="-1" selected="selected"> Please select </option> <option value="4"> a </option> <option value="5"> b </option> <option value="6"> c </option> <option value="7"> d </option> <option value="8"> e </option> <option value="9"> f </option> <option value="10"> g </option> <option value="11"> h </option> <option value="12"> i </option> <option value="13"> j </option> <option value="14"> k </option> <option value="15"> l </option> <option value="16"> m </option> <option value="17"> n </option> <option value="18"> o </option> <option value="19"> p </option> <option value="20"> q </option> <option value="21"> r </option> <option value="22"> s </option> <option value="23"> t </option> <option value="24"> u </option> <option value="25"> v </option> <option value="26"> w </option> <option value="27"> x </option> <option value="28"> y </option> <option value="29"> z </option> <option value="30"> 0 </option> <option value="31"> 1 </option> <option value="32"> 2 </option> <option value="33"> 3 </option> <option value="34"> 4 </option> <option value="35"> 5 </option> <option value="0"> 6 </option> <option value="1"> 7 </option> <option value="2"> 8 </option> <option value="3"> 9 </option> </select> Link to comment Share on other sites More sharing options...
Stilgar Posted January 17, 2011 Share Posted January 17, 2011 Hello, the problem is: _FFFormOptionselect searches in "text" mode only substrings. The chars a,c,e,l,s,t are then found in "Please select", too. If you searching for e.g 9 it should work, or you select the options by value. Stilgar jEdit4AutoIt PlanMaker_UDF Link to comment Share on other sites More sharing options...
RichardL Posted January 17, 2011 Author Share Posted January 17, 2011 Alright, that's quite funny. I tried 9 didn't work: D1 - 9 - __FFSend: FFau3.xpath=null... __FFRecv: _FFXPath_Error: ... contains(.,' 9 ')]", ... _FFXPath ==> No match: sin... and I tried trimming off the ; and a few other chars. Nothing worked. I've tried the "value" and that works. I don't wanted to use that because the mapping might change, and it makes the code different for every web-page possibly different for each DropDownBox. I will try _FFXPath, and change "Please select" to "=" then it won't match. Thanks again, Richard Link to comment Share on other sites More sharing options...
4ggr35510n Posted January 17, 2011 Share Posted January 17, 2011 Game automation. It's a server select list for some web browser game. Link to comment Share on other sites More sharing options...
RichardL Posted January 17, 2011 Author Share Posted January 17, 2011 I have to use several tedious sites at home an work, it's for all of them. I was trying to keep it non-specific, generally useful, and not say exactly what this is. If you like puzzles there are several clues in the content and I won't spoil it by telling. Richard. Link to comment Share on other sites More sharing options...
RichardL Posted January 19, 2011 Author Share Posted January 19, 2011 I thought I/we'd done it but no. The next setback is that the web-site changes the mapping of the DropDown box index values each time. Alright, I've read the html found out how its mapped, get the index value that I want, done. The problem is that the saved file A.html accepts the write, but the real web-page doesn't. Consolewrite(stringformat("D3 -%s%- -%s-\n", $id, $ddvix)) _FFFormOptionselect($id, "id", $ddvix, "value")] Console output for success in C:\a.html D3 -ctl00_MainPageContent_char1_DropDownList%- -29- __FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form[1]//select[@id='ctl00_MainPageContent_char1_DropDownList']//option[@value='29']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.selected=true;}catch(e){'_FFXPath_Error: '+e;}; __FFRecv: 1 Fail on-line D3 -ctl00_MainPageContent_char1_DropDownList%- -28- __FFSend: FFau3.xpath=null;try{FFau3.xpath=FFau3.WCD.evaluate("//form[1]//select[@id='ctl00_MainPageContent_char1_DropDownList']//option[@value='28']",FFau3.WCD,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue.selected=true;}catch(e){'_FFXPath_Error: '+e;}; __FFRecv: _FFXPath_Error: TypeError: FFau3.WCD.evaluate("//form[1]//select[@id='ctl00_MainPageContent_char1_DropDownList']//option[@value='28']", FFau3.WCD, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue is null So what is the difference on-line? The css file is missing offline, so it looks different, that does not matter? Something else? On-Change functions that are failing? Have they defended the page against repl? I'm nearly defeated on this, going back to MouseClick and Send. Any comments appreciated. Richard Link to comment Share on other sites More sharing options...
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