Jump to content

Recommended Posts

Posted (edited)

Hello everyone,

I'm green hand)

I can't find the solution why attached script doesn't work.

_ChromeObjSetValueByName        want to set value by name, but not executing these commands

 

#include "wd_core.au3"
#include "wd_helper.au3"
#Include <Array.au3>
#Include <Chrome.au3>

Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '] }}}}'
EndFunc

Func _ChromeSetInputValueById($sSession,$Id,$Value)
 $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']")
 _WD_ElementAction($sSession,$sButton,'value', $Value)
EndFunc

Local $sDesiredCapabilities, $sSession
SetupChrome()

_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.autoitscript.com/forum/")
_WD_Window($sSession, "maximize", "")
Sleep(500)

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='elUserSignIn']")
_WD_ElementAction($sSession, $sElement, "click")
Sleep(500)

$Username = "testlogin"
$Password = "testpassword"

_ChromeObjSetValueByName("auth",$Username)
Sleep(700)
_ChromeObjSetValueByName("password",$Password)
Sleep(500)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='elSignIn_submit']")
_WD_ElementAction($sSession, $sElement, "click")

 

 

Edited by Harutyun
  • Moderators
Posted

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

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

 

Posted
16 minutes ago, Melba23 said:

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Moderation Team

sorry, did you move already

Posted

@Harutyun  ==> how-to-post-code-on-the-forum

To post code on the forum, please use the following procedure:

Click the Code button on the editor toolbar.

Add_Code.thumb.png.a9cc8de8c69a1978c8a8d

Select the code type (for most people this will either be AutoIt or Plain Text - AutoIt is the default)

Paste or type your code and then click OK.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

Do you have the full Scite editor installed? If not you can download from this page.

I asked the above because the issue I see is that you are trying to execute a non-existent function (_ChromeObjSetValueByName) and Scite would have quickly pointed that out for you when you attempted to run the script.

FWIW, I do recommend using the function _ChromeSetInputValueById as written because it doesn't perform any error checking. You might want to take a look at using _WD_GetElementById,  _WD_GetElementByName and _WD_SetElementValue, which were recently added to the UDF as "helper" functions.

Posted
57 minutes ago, Danp2 said:

Scite would have quickly pointed that out for you when you attempted to run the script

there is no any error , after run all is done, only part of _ChromeObjSetValueByName isn't working

Posted
2 minutes ago, Danp2 said:

@Harutyun The code you posted doesn't contain a function named _ChromeObjSetValueByName, so I don't see how the code can even execute. 🤨

Please run the code using Scite and then post the complete results from the Scite output panel.

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Harutyun Harutyunyan\AppData\Local\AutoIt v3\test\fullScreen.au3" /UserParams    
+>17:17:45 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Harutyun Harutyunyan\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Harutyun Harutyunyan\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Harutyun Harutyunyan\AppData\Local\AutoIt v3\test\fullScreen.au3
+>17:17:45 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Harutyun Harutyunyan\AppData\Local\AutoIt v3\test\fullScreen.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
_WD_IsLatestRelease: False
_WD_IsLatestRelease ==> Success
_WDStartup: OS: WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.3.0.6 (Update available)
_WDStartup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="C:\Users\Harutyun Harutyunyan\AppData\Local\AutoIt v3\test\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"85.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"85.0.4183.83","chrome":{"chromedriverVersion":"84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310})","userDataDir":"C:\\Users\\HARUTY~1\\AppData\\Local\\Temp\\scoped_dir22524_419438348"},"goog:chromeOptions":{"debuggerAddress":"localhost:57350"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:virtualAuthenticators":true},"sessionId":"9e49fd4c61d82327fc5a5b4771027859"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9e49fd4c61d82327fc5a5b4771027859/url; $sData={"url":"https://www.autoitscript.com/forum/"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9e49fd4c61d82327fc5a5b4771027859/window/maximize; $sData={}
__WD_Post: StatusCode=200; ResponseText={"value":{"height":1056,"width":1936,"x":-8,"y":-8}}...
_WD_Window: {"value":{"height":1056,"width":1936,"x":-8,"y":-8}}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9e49fd4c61d82327fc5a5b4771027859/element; $sData={"using":"xpath","value":"//*[@id='elUserSignIn']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"ea484aa4-98e2-415b-a923-7d83c1944c4a"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"ea484aa4-98e2-415b-a923-7d83c1944c4a"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9e49fd4c61d82327fc5a5b4771027859/element/ea484aa4-98e2-415b-a923-7d83c1944c4a/click; $sData={"id":"ea484aa4-98e2-415b-a923-7d83c1944c4a"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ElementAction: {"value":null}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9e49fd4c61d82327fc5a5b4771027859/element; $sData={"using":"xpath","value":"//*[@id='elSignIn_submit']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"adf20a30-5ef5-44f3-872c-56c1ec1f466f"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"adf20a30-5ef5-44f3-872c-56c1ec1f466f"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9e49fd4c61d82327fc5a5b4771027859/element/adf20a30-5ef5-44f3-872c-56c1ec1f466f/click; $sData={"id":"adf20a30-5ef5-44f3-872c-56c1ec1f466f"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ElementAction: {"value":null}...
+>17:18:09 AutoIt3.exe ended.rc:0
+>17:18:09 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 24.71

this is the result

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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