In web automation selenium python when running code without a headless working fine but with headless chrome it navigates to the unexpected page

0 votes

Using Python/selenium running without headless mode is working fine but with headless Chromedriver it navigates to an unexpected page.[expected dashboard but in headless navigates to profile after login but in normal working fine]
Note: in geckodriver headless working fine
Python code:

if value == "True":

capabilities = DesiredCapabilities.CHROME.copy()       
if self.getPlateform() == "Windows":
    chromedriver = self.SRC_DIR +'yxyz\\chromedriver.exe'
    chromedriver = self.SRC_DIR +'yxyz/chromedriver'
    return webdriver.Chrome(
        desired_capabilities = capability
Jun 15, 2020 in Selenium by Raghvir
• 170 points
Hey @Raghvir, Are you getting any error in the process?
After login, I expected to user dashboard page but it navigates to the profile page. So the assertion fails.

Are you running it on a Linux or windows? As of today, when running chrome headless on Windows., you should include the  --disable-gpu flag

On both Linux and on the window as well.

Try something like this:

options = webdriver.ChromeOptions()
chrome_driver_path = "C:\Python27\Scripts\chromedriver.exe" //your chromedriver path
nothing can change....thanks for looking into this hope we will find solution soon
Hey @Raghvir, did the above snippet help? Did you find a solution? Please post it as the answer in case you found a solution for the same.
Headless chrome may be faster on same machine than headed, try adding some wait and check if it works.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,150 points
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points