Home > front end >  Html notification in if statement python
Html notification in if statement python

Time:02-27

I have a question. I'm trying a brute-force attack on my own account. If I try to log in too many times, I get a notification. To continue with password login I have to go back and re-enter my username. Once I've done that, I can continue brute-force.

Now I want to automate this too. When I got the notification, I inspected and copied the notification. This is the html code of the message. Especially the part "Your account is...contact your admin" seems the most important to me.

<div id="passwordError" data-bind="
                externalCss: { 'error': true },
                htmlWithBindings: passwordTextbox.error,
                childBindings: {
                    'idA_IL_ForgotPassword0': {
                        href: accessRecoveryLink || svr.urlResetPassword,
                        attr: { target: accessRecoveryLink &amp;&amp; '_White' },
                        click: accessRecoveryLink ? null : resetPassword_onClick } }" >Your account is temporarily locked to prevent unauthorized use. Try again later, and if you still have trouble, contact your admin.</div>

I want that when I get this message I can do something. I want to do this in python. I know already how I can move my mouse and click. I want to use this to type in my username again so I can continue to brute-force my account.

So I want to do something like this:

if (notification = true):
    movemycursorandclick

So I know the thing that must be done if the notification is true, but I don't know how I can know in python if I'm getting the notification. Can anyone help me out? If it is unclear for you or you have questions, please ask me.

CodePudding user response:

People usually use Selenium to control web browser and work with web page.

But if you use PyAutoGUI then you could try The Locate Functions which use image to detect element on screen and give its location (x,y).

So if you would have image of notification then you could use this image to detect notification on screen.

If notification has some unique button (to close it) then you could use its image to detect notification and it should give you position of this button so you could simply move mouse and click it.

  • Related