Skip to content
Advertisement

Clicked button doesn’t really function by Selenium Python

I’ve been trying to click a button that downloads a CSV file from “https://mol.org/regions/?regiontype=countries”. I’m sure that I’ve selected the button, as I can print the text written on it, but whenever I try to .click() it, it doesn’t download the file. Are there any additional steps needed to operate the function bound to the button? Thank you in advance.

PS : The button works manually.

Here is the driver code I used :

JavaScript

You can see that I actually print the button text & can access it, but the .click() is not working as expected.

Variables :

JavaScript

Advertisement

Answer

Your css selector looks perfect, but I think it's a page loading issue. So I tried that with an explicit wait command (check below) and it seems working fine.

Sample code :

so instead of this :

JavaScript

use this :

JavaScript

Update 1 :

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