Replies: 6 comments
-
Hi @Vesuvex - glad you are finding this project useful. It seems the default browser window size is system/screen resolution dependent. The default browser window size on my laptop is 1050x732. One thing you could try is to set the window size through capabilities: Sub test_size()
Dim driver As SeleniumVBA.WebDriver
Dim caps As SeleniumVBA.WebCapabilities
Set driver = SeleniumVBA.New_WebDriver
driver.StartChrome
Set caps = driver.CreateCapabilities()
'if this works for you, then preload capabilities so
'that it defaults each time you call OpenBrowser method
caps.AddArguments "--window-size=1000,750"
driver.OpenBrowser caps 'here is where caps is passed to driver
driver.NavigateTo "https://www.wikipedia.org/"
Debug.Print "width: " & driver.ActiveWindow.Bounds("width")
Debug.Print "height: " & driver.ActiveWindow.Bounds("height")
driver.CloseBrowser
driver.Shutdown
End Sub If the above works for you then you could pre-load the capabilities via the SeleniumVBA ini file as explained in the Wiki under Advanced Customization. Let us know if going in that direction solves your problem. Mike |
Beta Was this translation helpful? Give feedback.
-
Hi Mike, Thanks for the quick response Unfortunately, the above is not working for me. Below is what my Edge Looks like and also my code. ` Dim driver As SeleniumVBA.WebDriver
I've been digging deeper on how to change the default for msedgedriver but I got no luck in finding out. It would be really useful to know if there is a way to change the default settings. But if not I guess I would have to result in scrolling the window to find each element. |
Beta Was this translation helpful? Give feedback.
-
Try removing the Your code in previous message should work with that change (did on my system). Mike |
Beta Was this translation helpful? Give feedback.
-
In addition to using the After you get the capabilities working like you want to, then run the following to create the pre-loaded capabilities json file: 'set all of your "default" capabilities here:
caps.AddArguments "--window-size=1920,1080"
'...
'...
'now save capabilities to a json file path of your choice
caps.SaveToFile "%USERPROFILE%\Documents\SeleniumVBA\capabilities\edge.json"
'now create the SeleniumVBA.ini file if you don't have one already (will be placed in
'same folder as your SeleniumVBA code lib)
driver.CreateSettingsFile keepExistingValues:=True Then, edit the below portion of the ini file to point to the location of edge.json created above:
If you did all of that correctly, then you won't need to use the WebCapabilities object any longer to set the window size. Each time you call Good luck! |
Beta Was this translation helpful? Give feedback.
-
Hi Mike, Thank you so much for the help. I appreciate it. It turns out the solution was to set the profile to the chrome profile instead of edge and I was able to control the window from there. I understand the above solutions would've worked in my own laptop and apologies if I hadnt disclosed that the laptop I use have a lot of restrictions including updating edgedriver. I can share the final code as a solution for others if they encounter the same issue. Please let me know if anyone wants it. Regards, |
Beta Was this translation helpful? Give feedback.
-
Ok - happy that you sorted this out. I'm going to convert this to a discussion since it's really not an issue with SeleniumVBA, and so that others can refer to it if needed... Mike |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First of all this is a really good project and I am totally impressed by this.
Is there any way to change the default browser size to more than 800 x 600 without setting the size via driver.window or driver.activewindow?
I cant seem to change the default size and the viewport is stuck at 800,600
Thank you so much for developing this!
Beta Was this translation helpful? Give feedback.
All reactions