svenjatzu Posted January 24, 2020 Share Posted January 24, 2020 (edited) Hey coders, im trying to create a script that helps me a my daily office job. To understand the WebdriverUDF WD_demo im trying to klick onto "Allwebco Hosting" You find it here. http://allwebco-templates.com/support/S_script_IFrame.htm at the point " Sample website in an IFrame page" my ui recorder drops me this commands { "Command": "selectFrame", "Target": "relative=top", "Value": "" }, { "Command": "selectFrame", "Target": "index=1", "Value": "" }, { "Command": "clickAndWait", "Target": "xpath=//*[@id=\"contentbox-h\"]/div[8]/div/a/img", "Value": "" } when i add those to my script it sends an error frame not found. my code is this: #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sElement Local $sEmailAddress = 'xxx@gmail.com' Local $sPassword = 'xxx' SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) Local $sElement _WD_Navigate($sSession, "http://allwebco-templates.com/support/S_script_IFrame.htm") ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF) ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='1']") _WD_FrameEnter($sSession, $sElement) Sleep(5000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='contentbox-h']") _WD_ElementAction($sSession, $sElement, 'click') Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' EndFunc anyone can please help me with that? Edited January 24, 2020 by svenjatzu Link to comment Share on other sites More sharing options...
Danp2 Posted January 24, 2020 Share Posted January 24, 2020 Your xpath is wrong (id isn't the same thing as index). Try "//iframe[2]" P.S. Next time include the results from the Scite output panel so that we can review them Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
svenjatzu Posted January 24, 2020 Author Share Posted January 24, 2020 #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sElement Local $sEmailAddress = 'xxx@gmail.com' Local $sPassword = 'xxx' SetupChrome() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) Local $sElement _WD_Navigate($sSession, "http://allwebco-templates.com/support/S_script_IFrame.htm") ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF) ConsoleWrite("TopWindow=" & _WD_IsWindowTop($sSession) & @CRLF) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[2]") _WD_FrameEnter($sSession, $sElement) Sleep(5000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@id='contentbox-h']") _WD_ElementAction($sSession, $sElement, 'click') Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}' EndFunc >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\bluestagg\Desktop\scripts\test.au3" _WDStartup: OS: WIN_81 WIN32_NT 9600 _WDStartup: AutoIt: 3.3.14.3 _WDStartup: WD.au3: 0.2.0.5 _WDStartup: WinHTTP: 1.6.4.1 _WDStartup: Driver: chromedriver.exe _WDStartup: Params: --verbose --log-path="C:\Users\bluestagg\Desktop\scripts\chrome.log" _WDStartup: Port: 9515 __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\bluestagg\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}} __WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"79.0.3945.130","chrome":{"chromedriverVersion":"79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614})","userDataDir":"C:\\Users\\bluestagg\\AppData\\Local\\Google\\Chrome\\User Data\\"},"goog:chromeOptions":{"debuggerAddress":"localhost:38377"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"b3fc6207a1a7bd667906daa916265593"}} _WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"79.0.3945.130","chrome":{"chromedriverVersion":"79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614})","userDataDir":"C:\\Users\\bluestagg\\AppData\\Local\\Google\\Chrome\\User Data\\"},"goog:chromeOptions":{"debuggerAddress":"localhost:38377"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify"},"sessionId":"b3fc6207a1a7bd667906daa916265593"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/url; $sData={"url":"http://allwebco-templates.com/support/S_script_IFrame.htm"} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_Navigate: {"value":null} __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/execute/sync; $sData={"script":"return window.frames.length", "args":[[]]} __WD_Post: StatusCode=200; ResponseText={"value":2} _WD_ExecuteScript: {"value":2} Frames=2 __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/execute/sync; $sData={"script":"return window.top == window.self", "args":[[]]} __WD_Post: StatusCode=200; ResponseText={"value":true} _WD_ExecuteScript: {"value":true} TopWindow=True __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/element; $sData={"using":"xpath","value":"//iframe[2]"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"c50092cb-be5e-4b54-a0a7-ef8ecb0ed02b"}} _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"c50092cb-be5e-4b54-a0a7-ef8ecb0ed02b"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/frame; $sData={"id":{"element-6066-11e4-a52e-4f735466cecf":"c50092cb-be5e-4b54-a0a7-ef8ecb0ed02b"}} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_Window: {"value":null}... __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/element; $sData={"using":"xpath","value":"//div[@id='contentbox-h']"} __WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"56d8af47-02d2-4ab3-ac00-4eccf4fca010"}} _WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"56d8af47-02d2-4ab3-ac00-4eccf4fca010"}} __WD_Post: URL=HTTP://127.0.0.1:9515/session/b3fc6207a1a7bd667906daa916265593/element/56d8af47-02d2-4ab3-ac00-4eccf4fca010/click; $sData={"id":"56d8af47-02d2-4ab3-ac00-4eccf4fca010"} __WD_Post: StatusCode=200; ResponseText={"value":null} _WD_ElementAction: {"value":null}... >Exit code: 0 Time: 15.19 Link to comment Share on other sites More sharing options...
svenjatzu Posted January 24, 2020 Author Share Posted January 24, 2020 same error in here 😕 Link to comment Share on other sites More sharing options...
Danp2 Posted January 24, 2020 Share Posted January 24, 2020 6 minutes ago, svenjatzu said: same error in here 😕 Not sure what you mean. I don't see any errors in that output. 🤨 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
svenjatzu Posted January 24, 2020 Author Share Posted January 24, 2020 the error is that it doesnt klick on there Link to comment Share on other sites More sharing options...
Danp2 Posted January 24, 2020 Share Posted January 24, 2020 No, it appears to me that the script is running as written, but perhaps it isn't having the results you intended. What exactly do you expect to happen when you click on the element found with xpath of "//div[@id='contentbox-h']"? FWIW, Nothing happens when I manually click on this div, so I don't know what you would expect to occur. Perhaps you've targeted the wrong element? <shrug> svenjatzu 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Davidowicza Posted January 24, 2020 Share Posted January 24, 2020 (edited) Total assumption that you are trying to click here, but try changing your Xpath to the iFrame to: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='left-content']/div/iframe[2]") And the element you want to "possibly" click to: $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html/body/div/div[1]/a[1]/img") This was the only element in that iFrame that I could find that "did something". Tested and works for me at least. Edited January 24, 2020 by Davidowicza svenjatzu 1 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