This question already has answers here:
How to work while Selenium tests are working
(2 answers)
Closed 5 years ago.
I am using Selenium to automate a website. First, I open the main website with C#.
Then, I manually click to open new windows from the main site. Now, I want to scrape the data of these new windows. This is not an issue. The problem lies in the fact that Selenium seems to need a window to be focused to scrape it. I use the SwitchTo method currently before scraping. When you switch, the new windows pop to the front and steal focus from other windows. Is there a way to scrape a window without giving it focus?
Saying that “Selenium requires focus when scraping a page” is a gross oversimplification at best, and a complete misassignment if responsibility at worst. Whether a driver used by Selenium to automate a page requires focus is highly dependent on the driver’s implementation. You haven’t said what browser you’re using, but if it’s Chrome or Firefox, those implementations are created and maintained by the browser vendors (Google and Mozilla, respectively).
There are alternatives in both cases, as both browsers officially support a “headless” mode, which can be used with Selenium. Note, however, that use of that mode would require you to automate the steps you’re currently doing manually.
Answering straight, No Selenium can't scrape a window without the required focus.
It's not only Selenium needs focus. The WebElements with whom you intend to interact with, needs to be within the Viewport
Update:
As per your comment if you want to work through an alternatives to Selenium that wouldn't require focus the Answer is Beautiful Soup through Selenium Python Clients using urllib.request module.
Related
I am forced to use a RPA software and C# scripts at my current job to automate a website. Basically everything worked fine until i had to handle a webpage dialog box like the one found on this post!
The dialog box pops up when clicking a button and it seems to have some javascript functionality behind.
I have to say that using the selenium webdriver switchTo() method allows me to handle the popup, get the htmlDocument and complete my task. However, I am forced to use this RPA software which can use its own browser or the Internet Explorer browser, therefore can't use the webdriver from the Selenium library.
Is there any other way of handling this kind of popups? Maybe another library that gives me the Selenium functionality? The most important thing is being able to read the htmlDocument in order to have access to all the webdialog elements (e.g. radio buttons, checkbox, searchbox etc.)
This question already has answers here:
Is it possible to use Selenium with C# windows Form that contains a WebBrowser object?
(5 answers)
Closed 7 years ago.
I have been looking all over the internet for resources that explaining a way of using selenium with a C# Windows Form that contains a WebBrowser object. We have this project that requires implementing selenium to interact with the Embedded webBrowser.
Any resource would be useful.
I have looked into this but it gets no where.
Is it possible to use Selenium with C# windows Form that contains a WebBrowser object?
Thanks in advance.
No, its not possible to use selenium with your own browser. Selenium can be used only for browsers that selenium support (opera, safari, firefox, chrome, phantomjs, ie, etc)
But you can use native c# functionality for this. There is possible to do some actions as clicking on elements and some another, but its pretty poor.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Using HTML5/Canvas/Javascript to take screenshots
Is there a way for a browser to take a global screenshot ? I mean, the entire screen, including what is not in the browser.
I kown that I may sound a little bit silly by asking this.
There is experimental support for full-screen capture in Chrome's getUserMedia WebRTC function, using a {chromeMediaSource: 'screen'} parameter. The functionality currently requires explicit activation by an option in chrome://flags, and (like all WebRTC capture mechanisms) requires explicit consent from the user when the function is called.
Other than that experimental option in Chrome, is not possible using pure JavaScript, but you could probably do it using a plugin like Flash, or an ActiveX control.
If you only want to capture a web page (rather than the whole screen), see Using HTML5/Canvas/JavaScript to take screenshots.
I need to build a small application to compare site rendering in different browsers in different resolutions.
First I need to support IE, FF, Chrome and user will choose to preview her site in different resolutions.
WebBrowser control do not offer me this.
Can you tell me is there any control or library to solve this problem in C#, .Net?
Thanks in advance!
Stack Overflow itself provided some options.
I'd say you can put each one of the following into a TabControl, so the user can easily choose and switch view.
For Internet Explorer, stock WebBrowser control should do.
Firefox Wrapper (GeckoFX)
Chrome wrapper (Webkit.NET)
I'd like to use C# to interact with the IE browser.
I have a feeling that shdocvw.dll will be involved, but there are so many classes in there that I don't know where to start, and maybe it's not even necessary to use it.
The goal here is to interact with a website, visiting it's pages and "warming it up," not unlike as described here by Kenneth Scott. The thing is, javascript is getting executed as you interact with a website, so it would be nice just to be able to login / submit forms exactly as you would on the website itself.
Plus it would be nice to be able to create a program that records my actions in IE, and then be able to slightly automate and slightly modify them.
Additionally, it would be nice if it could do all this in the background, without having to display the webpage at all.
I'm not looking for third party solutions, I want to do this myself (with your advice of course.)
Thanks.
You said you're not looking for a third party solution, however, we have used WatiN in work with great success for automated UI testing.
It's open source, so if you want to see how they do it, you can.
Things like selenium and watin are very mature frameworks for doing exactly what you ask. Unless the point is to learn for yourself how to do this I would use one of them.
Watin is also a great way to learn how to do this in c# as it is an open source c# project.