AnnoyingClown Posted May 27, 2021 Share Posted May 27, 2021 Where I should direct my Xpath to paste text in to it? example website link http://www.raciborz.slaskie-ogloszenia.pl/ogloszeniaslaskie/dodaj Link to comment Share on other sites More sharing options...
Luke94 Posted May 27, 2021 Share Posted May 27, 2021 //body[@id="tinymce"] Does that work? Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 8 minutes ago, Luke94 said: //body[@id="tinymce"] Does that work? Nope Link to comment Share on other sites More sharing options...
Luke94 Posted May 27, 2021 Share Posted May 27, 2021 //body[@class="mceContentBody "] How about this? Keep the space after mceContentBody. Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 1 minute ago, Luke94 said: //body[@class="mceContentBody "] How about this? Keep the space after mceContentBody. Nope Link to comment Share on other sites More sharing options...
Danp2 Posted May 27, 2021 Share Posted May 27, 2021 @AnnoyingClown Post your code showing what you've attempted. P.S. Be sure that you account for the iframe. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 (edited) expandcollapse popuptestSlask() Func testSlask() OtworzLink("http://www.raciborz.slaskie-ogloszenia.pl/ogloszeniaslaskie/dodaj") Uzupelnij("//input[@id='titlepl_PL']","//body[@class='mceContentBody ']","","//input[@id='contactEmail']","","","","") _WD_Shutdown() EndFunc Func OtworzLink($sLink) _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, $sLink) _WD_LoadWait($sSession, 2000) EndFunc Func OgloszenieReadOpen() Global $hFileOpen = FileOpen($sFilePathOgloszenie, $FO_READ) Global $sFileRead = FileRead($hFileOpen) $sFileRead = StringReplace($sFileRead, @CRLF, '\r\n') EndFunc Func _WD_SetElementValueNew($sSession, $sElement, $sValue, $iStyle = Default) Local Const $sFuncName = "_WD_SetElementValue" Local $sResult, $iErr, $sScript, $sJsonElement If $iStyle = Default Then $iStyle = $_WD_OPTION_Standard If $iStyle < $_WD_OPTION_Standard Or $iStyle > $_WD_OPTION_Advanced Then $iStyle = $_WD_OPTION_Standard Switch $iStyle Case $_WD_OPTION_Standard $sResult = _WD_ElementAction($sSession, $sElement, 'value', $sValue) $iErr = @error Case $_WD_OPTION_Advanced $sScript = "Object.getOwnPropertyDescriptor(arguments[0].__proto__, 'value').set.call(arguments[0], arguments[1]);arguments[0].dispatchEvent(new Event('input', { bubbles: true }));" $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}' $sResult = _WD_ExecuteScript($sSession, $sScript, $sJsonElement & ',"' & $sValue & '"') $iErr = @error EndSwitch Func Uzupelnij($sXPtytul, $sXPogloszenie, $sXPwymagania, $sXPemail, $sXPfirma, $sXPwynagrodzenie, $sXPtelefon, $sXPnazwa) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sXPogloszenie) ;ogloszenie OgloszenieReadOpen() _WD_SetElementValueNew($sSession, $sElement, $sFileRead, $_WD_OPTION_Advanced) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sXPtytul) ;tytul TytulReadOpen() _WD_SetElementValueNew($sSession, $sElement, $sFileRead, $_WD_OPTION_Advanced) EndFunc Edited May 27, 2021 by Jos Added codebox Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 19 minutes ago, Danp2 said: @AnnoyingClown Post your code showing what you've attempted. P.S. Be sure that you account for the iframe. sorry it took so long, tried to make it readable for you @Danp2 Link to comment Share on other sites More sharing options...
Developers Jos Posted May 27, 2021 Developers Share Posted May 27, 2021 (edited) 8 minutes ago, AnnoyingClown said: sorry it took so long, tried to make it readable for you just read the post source page Edited May 27, 2021 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 @Jos sorry, i will do that next time Link to comment Share on other sites More sharing options...
Solution Danp2 Posted May 27, 2021 Solution Share Posted May 27, 2021 28 minutes ago, AnnoyingClown said: _WD_SetElementValueNew The enhanced version of _WD_SetElementValue was released a while back, so this function shouldn't be needed. 56 minutes ago, Danp2 said: Be sure that you account for the iframe. It doesn't appear that you are doing this. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 @Danp2 Yep that was the iframe, thanks! And about the SetElementValue, Sorry that I ask but what i should download, to make it work as intended? And my problem was from 8th May, its fixed that quickly? Link to comment Share on other sites More sharing options...
Danp2 Posted May 27, 2021 Share Posted May 27, 2021 Yes, the code for SetElementValue was updated on May 8th, and this enhancement was included in the latest release (v0.4.0.4). See my signature for the link to the latest version. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 11 minutes ago, Danp2 said: Yes, the code for SetElementValue was updated on May 8th, and this enhancement was included in the latest release (v0.4.0.4). See my signature for the link to the latest version. Ok, I downloaded and tested it, I still need to use ElementValueNew and replace my @CRLF with \r\n Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 @Danp2Also ElementValueNew stoped working for me, after patch Link to comment Share on other sites More sharing options...
Danp2 Posted May 27, 2021 Share Posted May 27, 2021 Sorry that it isn't working for you. Not sure how the update could have affected your local function. 🤨 Either way, I can't fix it unless I can determine why it isn't working. Can you provide a short script that would allow me to reproduce the issue? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 @Danp2 Yep that was my bad that ElementValueNew didn't work, fixed it for now, And Func testSlask() Local $sTestElement OtworzLink("http://www.raciborz.slaskie-ogloszenia.pl/ogloszeniaslaskie/dodaj") OgloszenieReadOpen() $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='descriptionpl_PL_ifr']") _WD_FrameEnter($sSession, $sElement) $sTestElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//body[@id="tinymce"]') _WD_SetElementValue($sSession, $sTestElement, $sFileRead) _WD_Shutdown() EndFunc Func OgloszenieReadOpen() Global $hFileOpen = FileOpen($sFilePathOgloszenie, $FO_READ) Global $sFileRead = FileRead($hFileOpen) $sFileRead = StringReplace($sFileRead, @CRLF, '\r\n') Global $hFileOpen = FileOpen($sFilePathOgloszenie, $FO_READ) $sOgloszenieReadOpen = FileRead($hFileOpen) EndFunc Func OtworzLink($sLink) _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, $sLink) _WD_LoadWait($sSession, 2000) EndFunc When i change from $sFileRead to $sOgloszeniaReadOpen it doesn't paste at all, also _WD_SetElementValueNew doesn't paste with white spaces, it just types '\r\n' on this one site Link to comment Share on other sites More sharing options...
Danp2 Posted May 27, 2021 Share Posted May 27, 2021 @AnnoyingClown This isn't what I was requesting because -- it doesn't run it requires additional resources (an external file) that shouldn't be required for a simple reproducer I did notice that you dropped the usage of , $_WD_OPTION_Advanced when you switched back to _WD_SetElementValue. Was this an oversight? 15 minutes ago, AnnoyingClown said: When i change from $sFileRead to $sOgloszeniaReadOpen it doesn't paste at all, also _WD_SetElementValueNew doesn't paste with white spaces, it just types '\r\n' on this one site Not really sure what all that means. You may need to switch to using a different technique like updating the innerHTML or innerText property instead. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AnnoyingClown Posted May 27, 2021 Author Share Posted May 27, 2021 @Danp2Sorry, will make it after work / tommorow Link to comment Share on other sites More sharing options...
Danp2 Posted May 31, 2021 Share Posted May 31, 2021 @AnnoyingClown Got your PM. Here's a simplified version of your script that sets the body element's innerText property instead of using _WD_SetElementValue -- #include "wd_core.au3" #include "wd_helper.au3" #include <String.au3> Global $sElement, $sTestElement, $sSession, $sFilePath='1.txt', $sDesiredCapabilities SetupGecko() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, 'https://justpaste.it/') _WD_LoadWait($sSession, 2000) Global $sFileRead = _StringRepeat("Test" & @CRLF, 10) $sFileRead = StringReplace($sFileRead, @CRLF, '\r\n') $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='tinyMCEEditor_ifr']") _WD_FrameEnter($sSession, $sElement) $sTestElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//body[@id="tinymce"]') $sScript = "arguments[0].innerText = arguments[1];" $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sTestElement & '"}' $sResult = _WD_ExecuteScript($sSession, $sScript, $sJsonElement & ',"' & $sFileRead & '"') Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}' EndFunc ;==>SetupGecko Latest Webdriver UDF Release Webdriver Wiki FAQs 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