# WebDriver UDF - Help & Support (III)

## Recommended Posts

Posted (edited)

After many hours trying to setup a private proxy, i've found a decent workaround and implemented it in AutoIt, ideas based on

6 hours ago, mLipok said:

@Danp2 could you take a look on this solution: https://stackoverflow.com/a/55582859/5314940

I'm not so good in this kind of things.

1. Just make an unpacked extension folder contains manifest.json and background.js, file templates are provided in the answer of the above stackoverflow question. By doing this you will expose your private proxy to those who access to these files.
2. Add an extra chrome switch --load-extension and its value will be the path to the unpacked extension folder (both using _WD_Option or set $sCapabilities will do) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log" --load-extension=path\\to\\unpacked\\folder') Or { "capabilities": { "alwaysMatch": { "goog:chromeOptions": { "args": [ "--load-extension=path\\to\\unpacked\\folder" ] } } } } Notice that the manifest.json is using some functions from v2 and will soon be deprecated in Jan 2023. I've attempted to migrate it to v3 but failed due to this known chromium bug. Edited by sylremo ##### Link to post ##### Share on other sites • Replies 1.1k • Created • Last Reply #### Top Posters In This Topic #### Top Posters In This Topic #### Popular Posts *click* to avoid posts of people that don't read, which I know hardly happens, but still....... @MarluyYour xpath needs to point to the desired Option element. Try this -- _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='country']//option[@value='BRAZIL']") https://developer.mozilla.org/en-US/docs/Web/API/Window/open#window_features Edit: It's often helpful to check out the internal code... in this case it's nice because it is passed to _WD_ExecuteS #### Posted Images Posted (edited) On 3/7/2022 at 2:31 PM, mLipok said: Starting review and investigation. Sorry for my late Fix is on the way, I just pushed PR on github. @carparso from where you get this following examples? I suppose that maybe from wiki or some of my examples - I want to check and change them. On 3/7/2022 at 2:17 PM, carparso said: Local$a= SetupEdge(False)
_WD_Startup()
$sSession = _WD_CreateSession($a)

Func SetupEdge($bHeadless) _WD_Option('Driver', 'msedgedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"') ;~ Local$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"excludeSwitches": [ "enable-automation"]}}}}'
_WD_CapabilitiesStartup()

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * *
IE on Windows 11 for 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 to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

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

"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"
, 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: 2022-03-07

##### Share on other sites
Posted (edited)

Hi, im currently in a really awkward situation. I slightly modified WinHttp.au3 to resolve personal issues,  my script works fine with modified version but the compiled version doesn't (both are in the same working dir). Then i tried to use Au3Stripper to see whats going on inside the stripped script and i realized that all WinHttp functions are being magically reverted to the initial state, i even take it seriously by empty the whole function but it still behaves the same way. Really weird and im so confused rightnow. I ensured that all the #include were set to the correct path.

In the case below, au3 version will immediately throw error to indicate that _WinHttpCrackUrl is not doing its job but the compiled version will work like nothing happened.

Edited by sylremo
##### Share on other sites

@sylremoI see that you are using vscode. Have you checked to see if you can replicate the issue using Scite?

##### Share on other sites

@Danp2
Unfortunately, using SciTe make no differences, all files are located in AutoIt Include folder, except for my main script changeproxy.au3.

Spoiler

And here is the original script compared to the stripped version.

Spoiler

@sylremoI suspect that you have a "stray" copy of the UDF that is being used instead of your intended version. First thing I would do is check your settings in the SciTEUSer.Properties file. What is the entry for "openpath.$(au3)"? Check any directories listed here for errant copies of the UDF. ##### Link to post ##### Share on other sites 29 minutes ago, Danp2 said: @sylremo SciTEUSer.Properties import au3.UserUdfs import au3.keywords.user.abbreviations ##### Link to post ##### Share on other sites Posted (edited) @danp2, i tried to completely uninstall and remove autoit program files folder, restart my pc, reinstall but nothing helps. Edit: welp, after many attempts, i finally managed to fix this issue by renaming WinHttp.au3 ... Edited by sylremo fixed ##### Link to post ##### Share on other sites @sylremoI would recommend that you start a new thread since this isn't a Webdriver UDF issue. ##### Link to post ##### Share on other sites Posted (edited) @Danp2, yes i shouldn't be discuss this problem here but still i did... I thought it would be a good idea to post here and get quick responses since this topic might be the most active place on the entire autoit forum. I'll try my best to avoid degression. Again, i appreciated your valuable time. Edited by sylremo ##### Link to post ##### Share on other sites @sylremoI have no issues with you posting here. I felt you might get a wider audience if you started your own thread. 🙂 ##### Link to post ##### Share on other sites Hi, thanks for the open source, it helped me a lot. But now I encounter a problem. When using _WD_FindElement to locate a button in the page, if the button can only be seen after dragging through the scroll bar, then clicking the button will return a failure message. Is there any solution? ##### Link to post ##### Share on other sites @liamashesUnder normal circumstances, the webdriver (chromedriver in this case) should handle any needed scrolling automatically. From the screen shot, it appears that you are calling _WD_ElementAction with the "value" command. Why would you do that on a button? ##### Link to post ##### Share on other sites Posted (edited) Hi @liamashes, like @Danp2 already mentioned, the scroll action to your element should be done automatically. But this sometimes depends on the page and DOM structure. Dealing with Angular/React with "shadow DOM" behaves differently then other (older web frameworks) without "shadow DOM" for example. That's why Selenium as a example provides a method .MoveToElement to do something like a hover over the element which triggers the scroll action. Maybe you find a similar approach for your requirement or you just focus the browser window by AutoIt (WinActivate()) and Send('{PGUP}') or Send('{PGDN}') to bring your element into the viewport. In case this wouldn't help, please provide a DOM snippet and more details/screenshots etc., thanks. Best regards Sven ________________ Stay innovative! Edited by SOLVE-SMART ##### Link to post ##### Share on other sites @SOLVE-SMART_WD_ElementActionEx provides the ability to hover over an element. 😉 ##### Link to post ##### Share on other sites @Danp2Both buttons and input boxes have this problem. Here is the behavior of simulating user login, you need to enter the user name and password. This log is the result of trying to get the input box and enter the user name. The browser does not scroll the page, but prompts that the interaction cannot be performed. The scenario mentioned above can be avoided by maximizing the window, but for buttons and input boxes that need to be scrolled to be seen in the page, the scrolling operation seems to be unavoidable.Is this problem related to the framework used for page development? ##### Link to post ##### Share on other sites @SOLVE-SMART@Danp2Thanks for your replies, I only saw this after reading the previous reply. @SOLVE-SMARTAs you said, the page here is developed using Angular, a very old framework. This is a commercial internal website, so it is not convenient to take screenshots. I don't know much about automated testing. The solution I can think of is to calculate the step size and scale according to the width of the scroll bar and the total width of the window. According to the scale, combine the position of the target element in the window to calculate the coordinates, and then drag the scroll bar to the corresponding position. coordinates, but this scheme is cumbersome. Will there be a solution to this problem in the future? Also, thanks for the implementation of webdriver you guys provided, it helped me a lot😁 ##### Link to post ##### Share on other sites Hi guys! currently i want to add proxy to my specified browser however it is not working. can you show me the error in my syntax. here is my code:$exe='C:\Users\Administrator\Chrome\browser\chrome.exe'
$exe=StringReplace($exe,'\','\\')
$profile=@ScriptDir&'\Chrome\Data\profile\'$profile=StringReplace($profile,'\','\\')$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true},    "binary":"'&$exe&'" ,"args":["--user-data-dir='&$profile&'", "--profile-directory=Default"],"proxy":{"proxyType":"manual","httpProxy":"119.98.114.154:6003","autodetect": "false"}}}'

##### Share on other sites

Use code tags when you post code. Post console error messages.

Take a look few post back, we was discuss the same things, and there are examples.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * *
IE on Windows 11 for 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 to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

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

"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"
, 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: 2022-03-07

##### Share on other sites
32 minutes ago, mLipok said:

Use code tags when you post code. Post console error messages.

Take a look few post back, we was discuss the same things, and there are examples.

#include "driver\wd_core.au3"
#include "driver\wd_helper.au3"

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Startup()
$exe='C:\Users\Administrator\Chrome\browser\chrome.exe'$exe=StringReplace($exe,'\','\\')$profile=@ScriptDir&'\Chrome\Data\profile\'
$profile=StringReplace($profile,'\','\\')
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true}, "binary":"'&$exe&'"    ,"args":["--user-data-dir='&$profile&'", "--profile-directory=Default"],"proxy":{"proxyType":"manual","httpProxy":"119.98.114.154:6003","autodetect": "false"}}}'$sSession=_WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession,'https://www.google.com.vn/?hl=vi')
_WD_LoadWait($sSession) _WD_DeleteSession($sSession)
_WD_Shutdown()

here is my code and the error report is as follows:
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stack...
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: missing command

I lost a lot of time and don't know how to set the proxy parameter properly. hope you can fix it

##### Share on other sites
• Danp2 changed the title to WebDriver UDF (W3C compliant version) - 07/29/2022
• Jos locked this topic
This topic is now closed to further replies.
• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...