Downloading chrome extension issue

78 views
Skip to first unread message

Zachary

unread,
Oct 17, 2018, 10:46:34 AM10/17/18
to Selenium Users
So I'm working on a project and I'm at a point where I need to download a certain chrome extension (I actually have to download it, I cant just set it as a chrome option in the code for reasons I am not going to specify at the moment). When you click "add to chrome" on any chrome extension from the chrome web store, it gives you a popup/alert asking you to "add extension". This is where I'm running into trouble. I cannot click the popup/alert. I need to click "add extension" but I cant figure out how. I have tried using the "switch_to.alert" function with selenium but that doesn't seem to find the alert box. I'm not positive if what is being displayed is classified as an alert or if it is something else. Any help with clicking the "add extension" button would be much appreciated.
I attached  a photo of what it looks like.


example.JPG

Zachary

unread,
Oct 17, 2018, 1:03:15 PM10/17/18
to Selenium Users
edit: I am using selenium with python 3 and running on a windows 10 machine.

Kenneth Exton

unread,
Oct 17, 2018, 4:38:36 PM10/17/18
to Selenium Users
If you are unable to find a built in way to switch to the download window an alternative would be to use pyautoit to call the needed autoit commands inside you python script. Autoitx does provide a python binding is why I say that. Also, when that window comes up how many window handles do you have? Just one or more than one?

Zachary

unread,
Oct 17, 2018, 6:06:46 PM10/17/18
to Selenium Users
When the window pops up, I still only have one window handle.
I've never dealt with pyautoit before. How exactly would that help me?

Thanks for the response

Kenneth Exton

unread,
Oct 18, 2018, 6:14:19 AM10/18/18
to Selenium Users
It’s only a suggestion for something to try. The reason I say try pyautoit is because as you mentioned there is no window handle so you cannot switch to it. In addition it is not behaving like a alert so the switch there is not working also. I’m thinking maybe selenium cannot see that pop up at all. In that case a couple of lines of pyautoit to do a window active to force control to your pop up, maybe a sendkeys tab and then a send keys enter to click the button might work. Also you can do a winactivate to set it to active then a win wait active to want until it is active before moving on to ensure stability. Maybe 4 lines of code or so. Also with pyautoit no external script necessary. Commands can be called directly in your autoit script.

Roy Toledano

unread,
Oct 18, 2018, 9:32:48 AM10/18/18
to seleniu...@googlegroups.com
Hi,
Thanks for reply. i can't see my post yet.

what is the meaning of winactivate? i can't find it under my driver.

‫בתאריך יום ה׳, 18 באוק׳ 2018 ב-13:14 מאת ‪Kenneth Exton‬‏ <‪kext...@gmail.com‬‏>:‬
It’s only a suggestion for something to try. The reason I say try pyautoit is because as you mentioned there is no window handle so you cannot switch to it. In addition it is not behaving like a alert so the switch there is not working also. I’m thinking maybe selenium cannot see that pop up at all. In that case a couple of lines of pyautoit to do a window active to force control to your pop up, maybe a sendkeys tab and then a send keys enter to click the button might work. Also you can do a winactivate to set it to active then a win wait active to want until it is active before moving on to ensure stability. Maybe 4 lines of code or so. Also with pyautoit no external script necessary. Commands can be called directly in your autoit script.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c58ee245-596f-4d29-86f9-e1a2f7e7ffd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
רועי טולדנו 

kext...@gmail.com

unread,
Oct 18, 2018, 12:34:30 PM10/18/18
to seleniu...@googlegroups.com
The reason for winactive is so autoit can interact with it. It makes the top window the active window. Note this is done independent of the chrome driver. Also, winactivate is part of the autoit dll which you will need to get from their website and add the include statement in you code. Also note to use pyautoit you will need to download it and run python setup.py install from a Cmd prompt. And in your code you will need a import statement “autoit” 

Sent from my iPhone

kext...@gmail.com

unread,
Oct 18, 2018, 12:44:32 PM10/18/18
to seleniu...@googlegroups.com
So for example in python if you wanted to active the notepad for example you could say: autoit.win_activate(“[CLASS:Notepad]”,””)
This would send control to notepad if notepad is running. After this then you could send text to it via sendkeys. 

Sent from my iPhone

Zachary

unread,
Oct 18, 2018, 2:07:38 PM10/18/18
to Selenium Users
Appreciate your time on this Kenneth.
I'm busy today but if I have some time tonight I'm going to try out your solution. I'll let you know whether or not it works.

Thanks again

Zachary

unread,
Oct 20, 2018, 3:09:00 AM10/20/18
to Selenium Users
I finally got around to trying out your solution. I was able to use pyautoit to send the key 'tab', and then send 'enter' to actually interact with the popup and download the chrome extension. 
Thanks so much for the solution! The only sort of bummer is that selenium isn't able to do it for some reason, so I cant really use a headless webdriver like I wanted to. But it isnt that big of a deal.
Maybe the developers of selenium will see this and try to fix the issue, or tell me what I'm doing wrong.

Thanks again,
Zach
Reply all
Reply to author
Forward
0 new messages