Search code examples
pythonpamie

How to open a New window in Python PAMIE


I am using PAMIE to auto log in to websites and I have a couple to do. I got the scripts down to do this but I can't get PAMIE to open a new IE window so when I run the script it just opens one logs in and then when the next one is open it closes the first and opens the second and so on. So how do I get PAMIE to open new windows. This is what I have..

website="https://website"
ie.navigate(website)
ie.setTextBox("username","Myusername")
ie.setTextBox("password","mypassword")
ie.clickButton("btnSubmit")

Then I want to do this again but need it in new window.

website="https://website"
ie.navigate(website)
ie.setTextBox("username","Myusername")
ie.setTextBox("password","mypassword")
ie.clickButton("btnSubmit")

I tried ie.new before navigate(website), if someone could please tell me what command to open a new window I would appreciate it. I have also trie ie.change.window, and can't get it to work. Thanks


Solution

  • The web page is being re-opened in a single IE instance, because you're only using one PAMIE instance. If you really want multiple IE windows open, you can use multiple PAMIE instances.

    Here is one very simple and crude example. Note that your import line may be slightly different than mine.

    from pamie30 import PAM30
    
    ie1 = PAM30.PAMIE("http://www.google.com")
    ie2 = PAM30.PAMIE("http://news.google.com")
    

    So now you can use ie1.navigate(), or ie2.navigate(), etc. to fill out the forms on your websites.

    For example, to use the first IE instance:

    ie1.setTextBox("q","my text goes here")
    ie1.clickButton("btnK")
    

    And when you're done with an instance you can kill it (it will leave the web page open, if you haven't done anything else with it), this just kills the Python object:

    ie1 = None