C# Selenium solving google ReCaptcha, iFrame issues - c#

currently, I automate some processes using selenium and need to solve Google ReCaptcha.
The technology used to solve the ReCaptcha is the browser, Plugin Buster.
I enter the Google ReCaptcha using the following
driver.SwitchTo().Frame(0);
driver.FindElement(By.Id("recaptcha-anchor")).Click();
Now I switch back to the default Frame using:
driver.SwitchTo().DefaultContent();
Now I try to enter the Google ReCaptcha Menu Frame and click the Buster icon, using the following code.
driver.SwitchTo().Frame(Indexoftheframetoenter);
driver.FindElement(By.CssSelector("#solver-button")).Click();
Icon to click
The problem with that is, the index seems to be a random lower number, which causes my code not to click the icon. I managed to "solve" this issue with ugly try and catch blocks, covering a specific amount of numbers. I am not familiar with iFrame. Is there a way to guess this specific iFrame?
Thank you very much

Update. It helped me to write down what I wanted.
Noticed you can also enter iFrames using their names. I leave this here for the community.
driver.SwitchTo().Frame("recaptcha challenge");

Google detects that it is a bot and does not perform the audio captcha, so this method will be of little use to you via selenium

Related

C# Selenium how to interact with chrome extension

I have successfully loaded my chrome profile with selenium that has pre-installed extensions.
The extension in question is called Private Internet Access, but i have tried others and cannot communicate with them
I am trying to figure out how i can open the extension below and enter username&password and click login button. I have tried finding the elements in by id and class but it doesnt find them. Can someone point me down the right line for this. Thanks
I've not had the ability to try this - however I've done a lot of work with Selenium and I've created my own chrome extension.
That extension popup in the top right actually a different web page. You won't be able to interact with it due to how it's presented, but you can navigate to it.
Try this:
Open up your extension, right click anywhere and select Inspect. This will open up devtools for the popup.
In devtools, go to the console and type document.url. This will give you the URL of that popup page. (you'll also see it at the top of the title bar)
That gibberish-looking bit in the middle doesn't change - it's your chrome extension identifier. From when I created my extension and 18 months worth of updates (including migrating from chrome extension manifest v2 to v3) it has not changed for me. I think you'll be safe to use it.
Go to that URL to make sure it works. In my case it's chrome-extension://ojhcleddagaoaplflbafhpekcciikdop/popup.html
You'll notice you'll lose some of the page styling compared to the popup. When you design the popup you give it fixed dimensions - when you open it as a normal webpage, you lose that and everything gets stretched.
Finally - for your automation - put that chrome-extension:\\ url as the first step in your selenium script and do your sign in. Then, carry on with the rest of your test.

Write into website cell using c# or WPF application

I have a very strange request that might upset some of you, anyway I want to write text or numbers in the website using C# or wpf software.
What I want is I pass string or number to the website when I press for example F11 on the keyboard and that number or string can be from a textbox.
Assume the following is Grid on a website:
Now I want to pass 0.01233 from textbox, to the highlighted cell in the website using c#.
Can anyone please how this can be achieved or at least guide me which direction I should go and achieve this.
Please Note I am not a developer of website and I have no control on website, I cannot write script on website
I've done something like this before, though I can't seem to find my old code. WPF has a WebBrowser control. You can use the Document property to access elements of the webpage an (if I recall correctly) execute scripts assosiated with those elements.
Of course it goes without saying that this would be a bodge at best, since any change made to the website could break your code.
Also, this forces you to use the WPF WebBrowser instead of your browser of choice.

How can I remotely take an accurate screenshot of a webpage by URL without WebBrowser?

I tried WebBrowser but any solution related to WebBrowser I find uses the exact same codes, WebBrowser.DrawToBitmap
Problem with that is, it gives out inaccurate results depending on URL, to what page actually would look like, sometimes even blank pages.
So I am looking for any alternate solution to WebBrowser if there is any.
It needs to run in background, as in not open any browser on screen, render it in background with all scripts and get an image.
If I understand what you're trying to do, you might be interested in a framework called PhantomJS, which is a WebKit "browser" engine which runs the pages without visually rendering them. It can be used to capture screens.
Now this technique requires JavaScript, but there is something called Selenium WebDriver to help you wrapping that. Users here at SO posted a simple example and this comment looks useful as it contains the list of required Packages.

screenshot of a webpage using asp.net without any exe

Is tat possible to get a screenshot of a webpage using asp.net without any exe?
If so please provide me some details or links.
Note: Since my hosting provider doesn't allow exe's to run, I can't use exes
Thanks in Advance
You can use something like Awesomium:
http://awesomium.com/
It's a fork of the Chromium browser, and has managed wrappers. It's designed for capturing screen shots and doing other "browser" things without the context of a window.
find some threads in stackoverflow, they maybe be helpful.
Javascript to take a screenshot of a website without using ActiveX
Take a screenshot of a webpage with javascript?

How to detect a rightclick in an application

my objective is to attach a context menu (vista and win7) whenever user right clicks a picture/file.
I've got the file portion down (ie, they right click on a file and my menu shows up) but I am having trouble understanding what I would need to do in terms of right clicking in firefox or ie .
I am trying to add a context menu whenever someone right clicks on an image file in IE or firefox. is that possible?
If you want to plug in to what happens inside the user's browser, you should probably write a browser extension to do that, instead of trying to hack up something awful that sort of does what you want maybe.
The best solution would be to develop a plug-in for the browser used by your user, whether it be for Internet Explorer, FireFox or Chrome etc..
Trying to create some sort of hack will only lead to a bad experience for your user so it's better to develop something that would work properly.
Here's a few links to get you going in the right direction:
Google Chrome: http://www.mattcutts.com/blog/write-chrome-extension/
Mozilla FireFox: https://developer.mozilla.org/en/Gecko_Plugin_API_Reference/Plug-in_Development_Overview
(I can't seem to find any for Internet Explorer)
I'm sorry i cannot give you a definitive answer but hopefully this should get the ball rolling for you at least.
is that possible?
NO
For Browsers: You need to develop an extension for each browser you want to support
For Desktop: http://www.codeproject.com/KB/cs/dateparser.aspx (ignore all the stupid istruction about how to catch the datetime )

Categories

Resources