0

Can you "get" multiple pages in parallel with chromedriver?

I am using Python, and as far as I understand selenium provides windowing API but does not allow opening a new window for a new driver.get() action. Trying to fetch a page while another is in process has proven problematic for me although I guess it might have been my wrong usage. Currently I am opening a number of chromedriver sessions in parallel, which in turn results with X 5 times chrome processes open - This can get intimidating although it seems to work. I am just wandering now if calling driver.get(url) on an existing session (after a previous page was retrieved) might open extra tabs/windows in the "internal" chrome process and bloat memory?

  • https://stackoverflow.com/questions/65088336/seleniums-webdriver-is-not-clearing-memory-after-quit-with-parallel-webdriver This guy runs multiple processes at the same time, maybe you find something interesting there – Timeler Dec 01 '20 at 21:18
  • It sounds like you are doing it right... you need one thread per driver per browser. Not real sure if you can multi-thread in python though. – pcalkins Dec 02 '20 at 00:10
  • Nope guys/gals you are both wrong. Just found out in the answer below. a windows can be opened using JS command windows.open() then using driver.get on current page + managing through selenium window_handlers. One session + one chrome browser (which employs 3~5 processes as normally would). No threads no multiprocessing :-) –  Dec 02 '20 at 05:38

1 Answers1

0

You can open links in a new window using selenium by forcing a context click: A couple suggestions: https://stackoverflow.com/a/19152396/1387701 https://stackoverflow.com/a/45582818/1387701

You can then use the switch_to command to switch between these windows. See more at https://www.browserstack.com/guide/how-to-switch-tabs-in-selenium-python

DMart
  • 2,401
  • 1
  • 14
  • 19