windows warning starting chrome with Selenium Python - python

I've just started coding in python with selenium, but here is my problem :
When I start Chrome with selenium,I ve a warning message from windows (my computer is in french, but it ask if I want to reset my setting). And I would like to close that tab, to make my program continue on another tab.
But it seems impossible to close it. I tried :
the Alert class of selenium, did nothing, the code just go through it
Moving mouse to the cross, or to "dismiss" (with selenium obviously) just the same
Switching tab, and close it (with selenium's control command), it doesnt change anything
Open Chrome with my usual settings (still from selenium), with that mode i can t open my url anymore, but i dont have the warning message too ...
I would be so grateful if someone had an idea, or have already had that problem. In fact, i would just want to dismiss it, to make my program run, without having to close the window at the start.
Apologize me for my english, that's not my native language, but I swear that I do my best :/
Thank you very much to all, feel free to ask me more informations :)
AR
Edit: I can't forbid you to put a -1, but try to explain me in which way it deserves it, then, I'll try to correct me, or to give more details.

Here the solution, even if I would prefer a patch from Selenium, because to my mind, that is a trouble comming from Selenium/python + windows + chrome combination : I ve created a new profile on chrome, add the X.add_argument("user-data-dir=...) It doesn't open my profile (I've maybe done a mistake in the path to the folder) BUT the warning message disappears with that line, all I wanted, then thank you very much Bill Bell ;)

Related

Gain colour of a known coordinate on screen in python

I'm trying to automate a specific task using python. I need to execute a specific task when a specific colour pops up on the display. For example:
During the automation process, when the code to open a web browser is executed and a web browser pops up,I need to make sure that it actually worked, by detecting the colour at the exact coordinate where the logo of the browser is situated. So that it confirms the browser is open, then I need to use that information to execute another code.
As we know, when we try to open a browser, there will be a lag to open up the browser. Since that lag will be different, I need to execute the next code only after opening the browser.
I have gone too far with my explanation, but if you got any idea from what I have just explained, please help me with what you know?

What does it mean to "restart" a program (in my case IDLE)?

This answer on Stack Overflow offers a solution I am trying to implement. In particular, see the sections "Installation Instructions" and "How to Use".
Can anyone tell me the steps required to "restart" IDLE?
New Information:
Just as people have suggested I thought this simply meant closing the program and opening it back up again...but I already tried that.
The other twist to my situation is that I'm working on a virtual machine so I was unable to do the installation of IDLE2HTML.py myself. My work's Help Desk had to do it so I cannot speak for the accuracy of their work. For now I'm assuming they did it correctly, but when I go to the "Options" menu there is no option to "Save as HTML".
My only guess at this point is that I still need to "restart IDLE".
Just wanted to double check if there was something else I could do before going back to my Help Desk department.
IDLE reads the idlelib/config-xyz.def files, including config-extensions.def, just once, when it starts. So any changes to config-extensions.def only takes effect the next time you start IDLE.
If you do not see 'Save as HTML' after starting IDLE, the extension is not installed properly.
It means you need to close the IDLE so that any changes made by the script can affect the IDLE
Simply close the IDLE either via the X, Ctrl+Q or File>Exit, then open the IDLE again.
If you are using idlelib module from a Python program then close your program and run it again.

I need to be able to close an internet tab, but i cannot close the browser

Im am writing a piece of code where it is vital that the browser stays open however i need to be able to close windows, to stop the browser from over populating. I have been using the webbrowser module but it seems that webbrowser doesnt have a way of close the tab once open. Any ideas?
Remember the browser must stay open, so killing all tabs will close the browser. I must only close the tabs that were opened by my code!
Any help would be greatly appreciated.
Sorry if this isn't in the right place, feel free to move it.
Software:
Python 3.6.4 (32 bit)
Modules used:
Time, Random and Webbrowser.
Webbrowser is a limited api module for interfacing with popular browsers.
The way I see it you have a few options:
Find a module pertaining to the particular browser you're dealing with.
Work with the api of the browser(s) you're working with directly
Request feature of webbrowser in the future, but won't help you now, as they likely won't implement it any time soon.

Python selenium: Firefox auto download everything

I am trying to download a csv file from a website and no matter how many MIME's I try for both saving and opening, the dialog box still appears. Is there a way to cover all MIME's at once or anything that might pop up?
Right now I'm using:
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/html")
fp.set_preference("browser.helperApps.neverAsk.openFile","text/html")
And other variations including a ton more MIME's. How can I auto download regardless of the MIME?
I solved my question with this:
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream")
fp.set_preference("browser.helperApps.neverAsk.openFile","application/octet-stream")
I had multiple preference statements, and I think that is what the problem was. Now I only have this one active and don't have any problems. Hope this can help someone else.

How can I program a macro that will do the clicking for me in a web game?

I'm currently playing Mr. Mine and I'm lazy to click 'sell' every 1~2 minutes.
I could use a mouse macro program that I can make the computer to do the clicking for me but this sounds like an inelegant method.
I was thinking about some way I could make a code that will hack into the web browser with the web game on and somehow send some kind of 'request' to the server that will sell the minerals.
I mean, after all, clicking it by hand eventually will send some request to the server so why not do this sending through a preprogrammed code?
I know my question is broad, so let me ask a few questions that will give me a lead to start on my project.
What to I need to learn to understand the 'sending request' part?
Is there anyone or any script that has already done what I want to do?
I'd like to take a look at the source code. (it's okay even if its not Mr.Mine. any other web game would also be of help)
Also, I'm currently interested in python so if there's any example in python, I'd be really thankful.
update: "I've solved the problem"
I'm just writing how I solved the problem just in case some other folk who just started Mr.Mine faces the same laziness that I did.
As it turns out, Mr.Mine doesn't actually exchange packets with its server. It only uses internet connection for initial loading of images and all that.(I think it is..)
If you right click on the Mr.Mine web page and view the html code of it, you'll find that its full of javascripts.
After roughly reading through these javascripts, my theory that this game doesn't rely much on packet data became more persuasive.
Anyway that's why I approached my problem at a javascript perspective and I finally got a solution
What you need to do is utilize chrome's developer tools.(I'm a chrome user)
You can access to this tool also simply by: from the mr.mine web page, right click anywhere -> click the very last button. Then you'll see some panel popping up at the bottom of the screen.
this tool enables you to fiddle with the html code or javascript in it.
I'm not good at this either since this is my first time actually using it for a practical purpose.
I just managed to scrape enough knowledge about this by googling to satisfy my needs.
In this new panel, at the top menubar, there's the 'Console' tab on the very right.
Click this and you'll see a command console.
This is where you can execute java commands within the javascript of the webpage.
Well from here, its strictly 'Mr.Mine' related.
From my previous rough reading of the javascript, I found that the sell buttons have been given the ID such as 'SB2', 'SB3', 'SB4', and so on.
So what I did was just type
setInterval(document.getElementById("SB2").onclick, 300);
at the command line and pressed enter.
this command will automatically press the SB2 button(which corresponds to 'Coal') every 0.3 seconds.
*Caution: you must have the 'selling' page opened when this code is executed. I found out that if the 'sell' page is not opened, the code doesn't work.
*Caution2: another funny thing is, even within the 'sell' page, if you transfer to the 'sell isotope' page, it will automatically sell Uranium 238. That's because the SB2 button corresponds to Uranium 238 in 'sell isotope' tab. So be careful!
*Caution3: if you do this, an error popup will constantly come up. I just enabled the 'never show this popup' checkbox and after that it just worked fine. But one side effect: the usual popup that came up after pressing the 'save' button no longer appeared... but its worth the sacrifice isn't it?
anyway, if you want to automatically sell other ores, all you have to do is type similar codes like:
setInterval(document.getElementById("SB3").onclick, 300);
setInterval(document.getElementById("SB4").onclick, 300);
... etc.
see that just changing the number after "SB" corresponds to the next ore(isotope) in the list.
Well, thanks for reading this much, and I hope other Mr.Mine users can be creative and do more through this technique.
You could use a packet capturing tool such as wireshark. With that figure out the format and data that the game sends to the server.
Once your know the structure you could write your script to intercept your game traffic, add the needed parameters and send requests on a timed basis. (This is all assuming it does encrypt its network traffic, in which case this may be a bit more difficult)
You may find some additional information with this search.
perhaps you can use http://www.sikuli.org/. i have successfully used this to do a fairly complicated automation routine for eve online.

Categories