'Selenium new tab in Thread
I have to process 20 sites at the same time using Selenium
class ThreadWithReturnValue(object):
def __init__(self, target=None, args=(), **kwargs):
self._que = queue.Queue()
self._t = Thread(target=lambda q,arg1,kwargs1: q.put(target(*arg1, **kwargs1)), args=(self._que, args, kwargs), )
self._t.start()
def join(self):
self._t.join()
return self._que.get()
class Some_Class:
def threads_setup(self,)
for link in links[:20]:
single_thread = ThreadWithReturnValue(target=self.core, args=(link, ))
ALL_THREADS.append(single_thread)
for thread in ALL_THREADS:
result = thread.join()
def core(self, link):
# i must open new tab and work with him
self.driver.get(link)
return some_value
If i work with
self.driver.execute_script("window.open()")
then all threads start to work for me only in the last tab
I would like each thread to work with a separate tab at the same time
How can I do it?
P.S class ThreadWithReturnValue i found in here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|