Jump to content

WebDriver UDF : restore windows


Recommended Posts

Hi @MWIProd ,

I don't know exactly what you're trying to achieve, but with the au3WebDriver project (WebDriver), the _WD_Window() function let you maximize, minimize etc. the browser window.
Could you describe your use case, then I am sure we could help you more precisely.

Best regards
Sven

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

I didn't see 'restore' in options Close|Frame|Fullscreen|Handles|Maximize|Minimize|New|Parent|Print|Rect|Screenshot|Switch|Window

This is why I posted here.

 

_WD_Window($_MY__WD_SESSION, 'rect', 'get')

gives me :

Quote

_WD_Window ==> Invalid argument [5] : Parameters:   Command=rect   Option=get

 

Link to comment
Share on other sites

I hardcoded the size and position, but you can extract it from the scripting dictionary object :

#include "wd_core.au3"
#include <File.au3>

Local $sDesiredCapabilities = SetupChrome()
_WD_Startup()
Local $sSession= _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://google.com")
;Sleep(5000)

$vRect = _WD_Window($sSession, "rect")
ConsoleWrite(VarGetType($vRect) & @CRLF)

  For $vKeys in $vRect
    ConsoleWrite($vKeys & "/" & $vRect.item ($vKeys) & @CRLF)
  Next

_WD_Window($sSession, "MINIMIZE")
Sleep(1000)
_WD_Window($sSession, "rect", '{"value":{"height":680,"width":948,"x":10,"y":10}}')

;_WD_DeleteSession($sSession)
_WD_Shutdown()

Func SetupChrome()
   _WD_Option('Driver', 'chromedriver.exe')
   _WD_Option('Port', 9515)
   _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')
   ;Return '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"]}}}}'
   Return '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
EndFunc

 

Link to comment
Share on other sites

Only out of curiosity @Nine , why do you define these "args"?

--user-data-dir
--profile-directory

Is there a specific need for it or is it just a "copy and paste" thingy?
I am really asking because I don't know why this should be defined 🤔 .

Thanks for any explanation 🤝 .

-------------------------------

@Danp2 could this be a improvement, to have something like ...

_WD_Window($sSession, 'restore')

in version v1.4.0 maybe? Besides that, I also see that the browser compatibility isn't very good 😔 .

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Link to comment
Share on other sites

14 minutes ago, Nine said:

Because I prefer to use my own personal profile, not a generic/empty one.

Okay thanks. Then I have to read about these settings/options more in depth, because I still don't see the advantages of it.

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

1 hour ago, Danp2 said:

Try using null for all values

Not working for me, what would be the syntax that you have in mind, I tried a few and no success...

NVM -- got it working, had a syntax error

Edited by Nine
Link to comment
Share on other sites

4 minutes ago, SOLVE-SMART said:

I still don't see the advantages of it

In some web sites, it will continually ask you to accept cookies for example.  But when you use your own profile, they will ask you only once. Same goes for un/pw, etc.

Link to comment
Share on other sites

Okay, that's a good one, thanks @Nine 👍 .

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

7 minutes ago, Nine said:

NVM -- got it working, had a syntax error

Can you please share how you did it? I cannot test it right now, but I believe to know how I would do it 😅 .
Thanks again in advance.

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Here :

_WD_Window($sSession, "rect", '{"value":{"height":0,"width":0,"x":0,"y":0}}')

restores as it should be.  Not obvious to know it.  Should be in help file, or like you propose to have a specific "restore" command.

Link to comment
Share on other sites

Thanks again. I was looking directly in the WebDriver documentation, not in au3WebDriver project.
I am a bit suprised now, because I would have used null instead of the zeros. Interesting ... .

I will also test it tomorrow and will have a look into the docs again.
Maybe I will create an GitHub issue (or even PR) for @Danp2. Then we will see 🤝😀 .

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Last words on this, for my side today:
There is a "normal" keyword which is also new to me. Maybe even better then the restore thingy. I don't know yet, but I will investigate a bit.

https://w3c.github.io/webdriver/#resizing-and-positioning-windows

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

I could verify your restore parameters (and syntax etc.) @Nine and could test it successfully on Chrome, Firefox and MSEdge.
I also created (a few minutes ago) an GitHub Issue and PR for this topic that can be reviewed by @Danp2 when he have the time for it.

I believe

_WD_Window($sSession, 'restore')

should be more intuitive or for some even more familiar like in other frameworks like Selenium or WebdriverIO.

Let's see what will happen 😇 .

-----------------

@MWIProd I guess this thread can be closed, right?

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...