1

I am trying to find a way that enables me to hide the driver (bot) of the selenium in VBA during the execution of the code and display it at end I can hide it using this line

bot.AddArgument "--headless"

But how I restore it?

Prophet
  • 32,350
  • 22
  • 54
  • 79
YasserKhalil
  • 9,138
  • 7
  • 36
  • 95

1 Answers1

3

No, it won't be possible to make Chrome operate initially in headless mode and then switch back to normal mode within the same session.

When you configure an instance of a WebDriver with Options() to span a new Browsing Context the configuration gets baked within the driver executable which will persist for the lifetime of the WebDriver and being uneditable. So you can't modify/add any existing/new configuration through Options() class to the WebDriver instance which is currently in execution.

Even if you are able to extract the Driver and Session attributes e.g. Session ID, Cookies, UserAgent and other session attributes from the already initiated Driver and Browsing Session still you won't be able to change the set of attributes of the Driver.
You can find more details in these discussions:

Credits to undetected Selenium

Prophet
  • 32,350
  • 22
  • 54
  • 79
  • Thanks a lot. Is it possible to minimize the bot window as I tried a lot and failed as for this point. https://stackoverflow.com/questions/53902049/ – YasserKhalil Mar 22 '22 at 19:32
  • 1
    1) I'm not really familiar with VBA Selenium so I can help with issues common to all the Selenium bindings, not specific to VBA 2) I see you got several answers there, they are looking good – Prophet Mar 22 '22 at 19:37
  • I can't get it to work properly. I really tried a lot but no real way ro do that. – YasserKhalil Mar 22 '22 at 19:38
  • Are you talking about minimizing the window? – Prophet Mar 22 '22 at 19:39
  • Yes about minimizing the window or if it is impossible to hide the bot and display it. Is it possible to use WIndows API to do such a trick? – YasserKhalil Mar 22 '22 at 19:41
  • 1
    I don't know, I'm sorry – Prophet Mar 22 '22 at 19:42
  • Some time ago I also tried to hide it and I didn't find a solution. I put the window in the corner and it's small, but I thought it was better to just minimize it and leave it like that without hide browser. – Julio Gadioli Soares Mar 23 '22 at 01:52