Answer the question
In order to leave comments, you need to log in
Why doesn't selenium open links in a new tab?
There was such a problem, for some reason selenium does not open links in new tabs.
Here is the code that worked before.
for group in tqdm(groups):
try:
self.ac.move_to_element(group).click().perform()
time.sleep(2)
self.driver.switch_to.window(self.driver.window_handles[1])
time.sleep(2)
urls.append(self.driver.current_url)
time.sleep(2)
self.driver.close()
time.sleep(2)
self.driver.switch_to.window(self.driver.window_handles[0])
except Exception as e: # it's just too many exceptions can happen here, catching every one would be too long to write.
print(e)
continue # sry for everyone reading that. P.S. I'm not ashamed.
return urls
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question