How to control IE Explorer with pywinauto - python

Ok, so I want to control a IE Explorer with pywinauto. I would like to select text fields on the page and edit them. Is there a way to do this with pywinauto without clicking where the text field are? The pages will be the same every time, but not the data that is entered into them. The window may not be in the same place every time, so I couldn't do WrapperObject.Click(coords=fixed_pos). Sample code is preferred. Thanks!

Unfortunately no. You can control the window of IE, all the toolbars and buttons, address bar and search bar, etc. But not content of pages within.
For this task, you need other tools, such as Selenium http://seleniumhq.org/
As for pywinauto,I strongly recommend to use the utility SWAPY http://code.google.com/p/swapy/. I am the Author of SWAPY. With it you can easily determine whether it is possible to manage the a control with pywinauto or not.

Related

How to detect any modal window on site Python selenium?

I make script which open site from text document (in document it about 150+ sites) and make screenshot of first screen. I have two problems. It is cookie alert and modal popup windows like "subscribe on our newsletter", "10% discount on this weekend" and something like this. Cookie alert was handeled by add crx extension before driver launch ( Pop up blocker for Chrome™ - Poper Blocker). But i not found something like this for modal windows. All modal windows have different xPath and class names. Like "modal", "ui-diaglod", "popup", etc. I have a question how to handle modals and dimming the background and after closing them make screenshot. I tried handle it by adding JavaScript script that searching modals by class names, but it so many classes that my solution didn`t work properly

Selenium + Python | QA Automating

I am automating some QA processes and I have some doubts along the way that do not allow me to move forward.
I have the following problems:
I need that when I open the Chromewebdriver, it automatically chooses the tab I want from the devtools, being Elements, Console, Recorder, Sources, etc.
What I could do so far is, when the browser is running, that the DevTools is open, but in its main tab, that would be elements
Extract information from the values of an extension (Is this possible?) The extension appears in the DevTools.
To add a kind of alert that does not allow you to advance if you do not click.
Take a screenshot (I could do this, but only the web page appears, and I would need that it appears besides the web, the DevTools).

Find element by background-image (Selenium Python)

I'm trying to send an automated email to Gmail. Yes, I know that it has its own Python library for that, however, as it is a business email, there is no way to get that automatic password that is generated by Gmail.
So I'm manually doing each step with Selenium.
At a certain point in the message, I must change the text color to red and then to black again. However, before pressing the color button, I must press another button first to open the color options:
button I mentioned
The button highlighted in red is where I'm having problems, because it has a div with the same class as others. Then I noticed that one thing I could use to differentiate would be the backgroud-image, but I don't know if I would be able to find the element by the class and background-image.
It is possible? If not, what other way can I click on this button, other than through XPATH, as the program has to run on other computers as well, so preferably through CSS_SELECTOR.
div
PS: All id's are dynamically generated, so there's no way to use them.

Selenium unable to automate click on web element

I should start by saying that I'm not a web developer but I have been using Selenium with Python for a few weeks and think I've gotten the basics down.
What I have is a page with a weekly calendar on it. Image as follows:
What happens is that you can click on any of the coloured boxes which will bring up a register for a class. It features items that you can click on which bring up new information. The problem I have is that I can't click on the items - or, rather, I don't know how to automate the click. I have automated clicking with Selenium before in other situations.
That looks as follows:
As you can see, the calendar still appears in the background. That is to say, the item we click on doesn't take us to a new page but, I suppose, runs some kind of method which shows the register and populates it with data.
My problem is this: I want to automate the process so that I can click on each of these items then scrape the information. In order to do that I need to be able to automate the clicking for each of the items.
So what have I done? When I've done this before, I've searched through the web html for the relevant part and then grabbed the xPath to the element I needed. But here I can't do that. Why not? Well, firstly, I just can't find that element!
Take a look at this close up of the first column:
It's divided into columns, but then I'd expect the clickable area to be an element within that. As you can see, it's not. Furthermore, the clickable area is just the coloured box itself, but if you look closely you can see the element goes outside of that area. I have gone very close with my mouse cursor to see exactly what's clickable, and it definitely is just the coloured box.
So I've not been able to get the element at all.
I thought I might be able to just find out where we went after I clicked the button, but when I got the link address, it just said it was the same page with no differences.
I appreciate I'm asking quite a broad question here, but the problem is that I don't really know where to start. If someone could give me at least that much, I would be grateful. Like if I could just click on each of these one at a time... I've found where the populated data is so I could grab that without a problem.
Well, here's to hoping.
Edit: I should add that there are some JavaScript items (tag type script, type='text/javascript'). I presume that the answer is in there somewhere, but there is a lot of Javascript and I'm not adept at reading it. It's hard for me to tell what script does what. If I could at least figure out what script runs when I click the item then I think I'd be onto something, but I have no idea. Even that would help me.
I had encountered similar problem when scraping for Instagram followers in mobile view where it was floating box when showing the accounts followers name. The approach I took was identifying the name of floating dialog box and clicking the element in it. It might different in your case of html.
Trying looking at this link. Selenium Scroll inside of popup div
Hard to say without the HTML. Maybe try Katalon Recorder (chrome extension) and see if that can detect the xpath for you? It might also be you have to use some kind of javascript to invoke the method for the element

Selenium: Testing pop-up windows

I have an issue when trying to test a web application with Selenium/Python. Basically I can't test elements of a pop-up window.
A scenario: I can test all elements for a page. But when I go to click on a button that opens up a small pop up box I can't test the elements on the popup. It's like the pop up isn't in focus or active.
I can test elements on the next page. For example click a button, brings me on to next page, and I can work with elements on the 'next' page. So it the problem seems to be popup specific.
I could post code but to be honest it might confuse at this stage. I may post code in a later post, thanks
There is a property called switch_to
Q: How do I handle pop up windows?
A: WebDriver offers the ability to cope with multiple windows. This is done by using the WebDriver.switch_to.window(knownName) method to switch to a window with a known name.
If the name is not known, you can use WebDriver.window_handles to obtain a list of known windows.
You may pass the handle to switch_to.window(handleName)
For example I used driverName.switchTo.window(driverName.getWindowHandle()) to get a hold of popups for which I didn't want to look for names.
Additional references:
http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions
For the Selenium RC API, you need to use the SelectWindow command to switch to the pop-up window. The window can be specified either by its name (as specified on the JavaScript window.open() function) or its title. To switch back to the main window, use SelectWindow(None).

Categories

Resources