1

I am trying to create a multi-thread programming using python selenium.In my program i want to open 50+ different urls simultaneously, so my code is opening each url in different browsers.Whenever i ran my program my cpu utilization is reaching 100%.So sometime some of the urls are not opening.

So My question is if i open multiple tabs within single browser is it reduce my cpu utilization ?

If yes, please help me to open multiple tabs in single browser using python selenium.

Divya Mani
  • 203
  • 1
  • 3
  • 15
  • as a test, open several tabs and watch your `Task Manger`/`Activity Monitor` and note the %utilization, now compare it with when you open multiple windows – onlinejudge95 Jan 23 '20 at 07:16
  • https://stackoverflow.com/a/18150682/11900212 . I referred this ..Making me confusing – Divya Mani Jan 23 '20 at 07:25

2 Answers2

1

You can open a new Tab utilizing JavaScript:

browser.execute_script('''window.open("http://example.com","_blank");''')

And than you can have a look at the cpu utilization as suggested by @onlinejudge95 in the comments.

Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46
  • I am using python selenium. – Divya Mani Jan 23 '20 at 07:24
  • Yes. I know. 'browser' is your selenium Webdriver, see:https://selenium.dev/selenium/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html?highlight=execute_script#selenium.webdriver.remote.webdriver.WebDriver.execute_script – Mailerdaimon Jan 23 '20 at 07:44
0

Open Multiple Tabs in one browser will speed down your program, As webdriver will work only in one tab and then will move to the second tab. can't work simultaneously. its same as to reduce the number of URLs.

Adnan Asghar
  • 64
  • 1
  • 7