1

I'm new to Chrome headless and I have a problem.

I want to randomly select two links from a web page on the page being viewed and open them at the same time.

Indeed my goal is to be able to have the screenshots of the three pages using Selenium with Chrome headless the one currently being viewed and the other two open.

The following code already gives me the screenshots script of the current page.

 from selenium import webdriver
 
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
 
driver = webdriver.Chrome('/home/leonel/projet_/chromedriver')
driver.get('https://openclassrooms.com/forum/sujet/ouvrir-un-lien-cliquable-present-sur-une-page-web#93235610')

driver.get_screenshot_as_file('/home/leonel/projet_/screenshot.png')

print(driver.title)
3
  • 1
    Is it multithreaded ? Commented Jun 26, 2019 at 20:33
  • I have my URL database and I want that after opening a page, I can have the possibility to have the screenshot of other pages in the same domain. So getting out of it Chrome headless must give me the screenshot of each page. So for one URL I have three screenshot coming out. If there are sites in JS that do not allow this, so much the better. I have several URLs and I thought there is certainly something that could allow this. Commented Jun 27, 2019 at 0:31
  • Selenium cannot work like this. You can have one page active and take a screenshot of it, but you cannot have a screenshot of 3 windows at the same time as selenium has only one active window at the given point. You are able to open 3 windows and then switch between them and take 3 different pictures. Commented Jul 1, 2019 at 8:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.