Skip to content
Advertisement

Selenium click on ng-click button

I am trying to automate a website with selenium to download an excel file. I have the following HTML for the button:

JavaScript

I have tried clicking on the button with the following find element by class:

JavaScript

The error message I get is:

JavaScript

I have also tried:

JavaScript

And received the following error:

JavaScript

I have logged in this website successfully and worked my way around the site up until the excel file page, but I can’t figure out how to click this button.

I have written my script as headless chrome if it makes any difference.

Update:

This is my whole code:

JavaScript

When I disable headless chrome option the file is being downloaded

Advertisement

Answer

find_element_by_class_name() doesn’t accepts multiple class name. Instead you can use css selector.

To avoid synchronization issue Induce WebDriverWait() and wait for element_to_be_clickable() and following css selector.

JavaScript

You need to import below libraries.

JavaScript

Reference link for css selector

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement