Jump to content

WebDriver UDF - Help & Support (III)


Danp2
 Share

Recommended Posts

On 9/19/2021 at 12:03 AM, seadoggie01 said:

Working with arrays: https://www.autoitscript.com/wiki/Arrays

"I do not think it means what you think it means". A profile is based around a user, so you might have multiple profiles if you, your mom, and your dad all use the browser. You can have multiple of these running, but I think it's (usually) silly to use them. Edit: in your script... elsewhere makes sense.

You can have multiple instances (called a session) of the browser running. This is like right clicking your browser and selecting "New Window". To do this, simply call _WD_CreateSession twice in a script, or once in two scripts. Be wary of calling _WD_Shutdown if they use the same driver instance (probably called a process?), however, because this can cause all sessions running with that process to be closed.

Finally, check out the WebDriver wiki: https://www.autoitscript.com/wiki/WebDriver. Great stuff there and will answer a bunch of questions you have! :)

I think that is not what I am looking for. For instance, I want to open 2 separate profiles with 2 distinct twitter accounts, and make them like and retweet. So If I open new window, that would not happen as I intend to do. I am looking for a solution to deal with this, I tried to run program twice to see how it go but when I did that, chromedriver went off.

Link to comment
Share on other sites

11 minutes ago, Danp2 said:

@ThePoroYou can use the following command to prevent the automatic closure of an existing webdriver console when calling _WD_Startup() --

_WD_Option('driverclose', False)

 

Yes I saw your comment on the other thread and it doesn't turn off anymore, but problem right now is the program works just fine if I don't use an existing user profile (worked ok with default $sDesiredCapabilities in wd_demo).

For example, I use profile 1 and run it first with this 

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Profile 1"], }}}}'

It runs well with this, but If I run 1 more time with another Profile (Profile 2). This happens in chromedriver console

Opening in existing browser session.

and This in autoit console

_WD_Startup: Existing instance of chromedriver.exe detected!
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\PoRo\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Profile 2"], "excludeSwitches": [ "enable-automation"]}}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: user data directory is already in ...
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir","stacktrace":"Backtrace:\n\tOrdinal0 [0x0099D403+2479107]\n\tOrdinal0 [0x00937D51+2063697]\n\tOrdinal0 [0x008420C8+1056968]\n\tOrdinal0 [0x0085D0E1+1167585]\n\tOrdinal0 [0x00859B7F+1153919]\n\tOrdinal0 [0x00889CBF+1350847]\n\tOrdinal0 [0x0088992A+1349930]\n\tOrdinal0 [0x0088583B+1333307]\n\tOrdinal0 [0x00861F94+1187732]\n\tOrdinal0 [0x00862DE9+1191401]\n\tGetHandleVerifier [0x00B1F3F6+1531734]\n\tGetHandleVerifier [0x00BCE9AE+2249998]\n\tGetHandleVerifier [0x00A239AB+501003]\n\tGetHandleVerifier [0x00A22A29+497033]\n\tOrdinal0 [0x0093D11D+2085149]\n\tOrdinal0 [0x009411C8+2101704]\n\tOrdinal0 [0x00941302+2102018]\n\tOrdinal0 [0x0094AA71+2140785]\n\tBaseThreadInitThunk [0x75E2FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x770B7A9E+286]\n\tRtlGetAppContainerNamedObjectPath [0x770B7A6E+238]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir","stacktrace":"Backtrace:\n\tOrdinal0 [0x0099D403+2479107]\n\tOrdinal0 [0x00937D51+2063697]\n\tOrdinal0 [0x008420C8+1056968]\n\tOrdinal0 [0x0085D0E1+1167585]\n\tOrdinal0 [0x00859B7F+1153919]\n\tOrdinal0 [0x00889CBF+1350847]\n\tOrdinal0 [0x0088992A+1349930]\n\tOrdinal0 [0x0088583B+1333307]\n\tOrdinal0 [0x00861F94+1187732]\n\tOrdinal0 [0x00862DE9+1191401]\n\tGetHandleVerifier [0x00B1F3F6+1531734]\n\tGetHandleVerifier [0x00BCE9AE+2249998]\n\tGetHandleVerifier [0x00A239AB+501003]\n\tGetHandleVerifier [0x00A22A29+497033]\n\tOrdinal0 [0x0093D11D+2085149]\n\tOrdinal0 [0x009411C8+2101704]\n\tOrdinal0 [0x00941302+2102018]\n\tOrdinal0 [0x0094AA71+2140785]\n\tBaseThreadInitThunk [0x75E2FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x770B7A9E+286]\n\tRtlGetAppContainerNamedObjectPath [0x770B7A6E+238]\n"}}
_WD_CreateSession ==> Webdriver Exception: HTTP status = 400

 

Link to comment
Share on other sites

1 hour ago, ThePoro said:

"message":"invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir"

This message seems pretty clear to me. You'll need to use a different "--user-data-dir" value for each instance.

Link to comment
Share on other sites

7 hours ago, Danp2 said:

This message seems pretty clear to me. You'll need to use a different "--user-data-dir" value for each instance.

So this means I have to move my profiles to other place before running it. Even those profiles are located in distinct folder? 

C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1
C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2

This seems not right to me because those profiles are always created and stored in (*\\Chrome\\User Data) and now I want to use both of them in the same time, I have to move 1 of them to other place.

Link to comment
Share on other sites

2 hours ago, ThePoro said:

So this means I have to move my profiles to other place before running it. Even those profiles are located in distinct folder? 

Seems that way. <shrug>

Maybe someone else will have some ideas on how you could fix this. Or you could possibly find the solution by searching the web for answers.

Link to comment
Share on other sites

  • 2 weeks later...

Hi @Danp2,

Just a quick question.
What is the fastest way to open a Chrome Window (let's say google.com) without bar's and stuf (just like a popup or the APP function in Chrome).

At the moment i am using the nasty way to open a session, then minimize that session and open a new tab as floating window.
But it seems a little bit 'nasty' using _WD_NewTab and _WD_Window (rect) to get the popup.

isn't there something like; create session in APP or POPUP format?

 

Thanks! :)

Link to comment
Share on other sites

@TungNhoc This is the 2nd time you've posted this question to the wrong thread. The first time one of the nice Admins moved it for me to the correct thread. Please post any future questions on the UDF to the thread in General Help & Support (link is in my sig).

P.S. I don't know the answer to your question. You may want to start a new thread in GH&S section where you can provide further details, what you've tried thus far, etc.

Link to comment
Share on other sites

_WD_GetSource($sSession)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

22 hours ago, Danp2 said:

@BluemanIDK and don't have time to research ATM. Have you tried Googling for a solution?

Hmm, yes i tried but couldn't find something about it, sadly.

So i thought, i will ask the all-knowing Danp2 :)

Edited by Blueman
Link to comment
Share on other sites

@Blueman You can try adding --app="<full url including https://>" as a command-line argument. It works from the command-line, but I'm too lazy to try with WebDriver rn

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

without more detailed information, only this answer can be given

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ......
_WD_ElementAction($sSession, $sElement, 'click')

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 07/29/2022
  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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