Selenium clicking alternative - c#

I am trying to use Selenium to automate the use of a web service.
Whenever I try to click on elements within the web page using Selenium the result is strange, it seems as if the web page is able to detect whenever I click using Selenium.
Whenever I click using my cursor the web page functions normally even if I set a break point mid application and start clicking it works fine.
Is there any alternative in .NET or Python that I could use to automate clicks in a similar fashion or perhaps avoid detection of these clicks on the service?
action.MoveToElement(element, 158, 208).Click().Build().Perform();
Thread.Sleep(5000);
for (int i = 0; i < 5; i++)
{
action.MoveToElement(element, 258, 158).Click().Build().Perform();
Thread.Sleep(2000);
action.MoveToElement(element, 228, 158).Click().Build().Perform();
//var screenshot = new Screenshot();
//screenshot.CaptureScreen(Convert.ToString(i + 1) + ".png");
Thread.Sleep(2000);
}
The service is an image service, whenever I click done to confirm that image has been processed, it will keep the image visible rather than making it disappear but when I interrupt and click it myself, it will disappear. The reason this is bad is the visible image will overlay the new image, the selenium clicked image will stay visible and manual clicks will not.
I am using the latest version of ChromeDriver and Selenium however I have tried Mozilla & IE with and other versions of selenium and web drivers with no avail.

The idea of putting CAPTCHA on a site is exactly to tell machines and people apart, so
seems as if the web page is able to detect whenever I click using Selenium
is working as designed. For simple captcha you can call some free ocr.space online OCR service. This will work just fine as long is an image with a text. You can also try Google Cloud Vision OCR which works equally well, but it is a bit more complicated to set up.

Related

C# selenium chromedriver - no see update on webpage

I use Selenium for a study project, to scroll Amazon Webpage and save items in result, price, ...
My code works, I can get all items link in the page, and then get data about its.
But my issue is that when I refresh the page, I could not see new items which appears in result (visible for any other browser). Selenium can't see it until I go to Chromedriver. When I goes to ChromeDriver (so when it become active windows?) and scroll down on the webpage, then Selenium could see the new item in the list send by Amazon.
To try to avoid this, I change between several page of Amazon, but when I comeback to the wanted page, new items are not visible.
driver.Navigate().GoToUrl(url);
I also try refresh and scroll down without success.
driver.Navigate().Refresh();
driver.Keyboard.PressKey(Keys.PageDown);
I'm not sure if it's because the chromedriver is not the active windows (but if I have to set it as active windows I can't have several windows in the same time, and can't work on my computer at the same time). If I stop ChromeDriver and restart it, he saw new items in the result. Do you think it's link to javascript use by Amazon?
Thanks for your help / ideas.

Focus on Textbox works in debug, losing when deploy to a server

I have an asp.net app that I am trying to run on an intranet. It uses a barcode scanner to scan a badge and then validate the entry. After I scan I set the text back to blank and setup to scan another badge.
scanNumber.Text = "";
scanNumber.Focus();
This works in debug mode on my standalone development PC and it even worked on the virtual test server. But when we moved it to a physical server and it's own intranet. It will not send the cursor back to the textbox. I have to use the mouse to move the cursor into the textbox.
I'm new to C# so I imagine it is something simple. I've tried a number of ideas from here, but can't find anything that works for me. Any more ideas?
Try to use the ScriptManager to focus to it instead.
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
scriptManager.SetFocus(scanNumber);
https://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager(v=vs.110).aspx for a reference that contains the method.

WatiN - Set the position of a browser

Im testing my website using WatiN , and for a specific test I'm opening few IE windows and work on them simultaneously.The problem is that the windows are opened in the same position and i can't see what is going on inside the windows. Any ideas?
I'm looking for something like:
var browser=new IE();
browser.SetPosition(top_left_X,top_left_Y);
Swapping between windows
To bring one of the browsers to the front use the browser BringToFront() method.
Like:
IE ie = new IE();
ie.GoTo("www.cnn.com");
IE secondIE = new IE();
secondIE.GoTo("www.google.com");
secondIE.BringToFront();
Resizing windows
To resize the windows and make them both viewable, say side by side, I believe you'll need to use something like SetWindowPos() or PInvoke's movewindow(). You can use ie.hWnd to get the window pointer to the browser. Unfortunately it has been a really long time since I've done anything like that and can't put together an example now, or even guarantee it is the right course of action.

WatiN has a bug in needed the window open to do successful screen capture

I recently started a job with a company that is wanting me to make a .NET solution using WatiN that automates the capture of different screens on their website, and the problem I've been running into is getting black screen shots when I capture web page images if the browser is minimized or not visible. Is there a way around this or a spot in the source code where I can "fix" the non rendering images of a minimized browser, or is this just a limitation I have to work with?
Thanks for any help guys!
I'm assuming you are running the watin tests with Internet Explorer? If so try adding the test site to IE's trusted sites list.
I generally use Nunit for Watin Integration test pass / fail detection. However, that aside, are you calling the BringToFront method prior to capturing the screen shot? EG:
[TearDown]
public void TearDown()
{
if (TestContext.CurrentContext.Result.State == TestState.Failure ||
TestContext.CurrentContext.Result.State == TestState.Error)
{
Browser.BringToFront();
Browser.CaptureWebPageToFile(DateTime.Now.ToString("ddmmyyyyHHmmss") + GetType().Name + ".png");
}
Browser.Close();
}

SpicIE toolbar, SHDocVw.IWebBrowser2 execScript problem?

I'm developing an addon for IE8+.
Main function:
- when I click the toolbar, it will display a box inside every single page, ex: google.com, bing.com, codeproject.com... by using execScript to execute jQuery.
Therefore, what Im doing is run javascript in the current page.
Everything has done except when that page perform an Pop-up, it doesnt work anymore.
I click the toolbar, nothing happen, but when I look at the pop-up, surprise! has the box which im trying to display. So, I think the current tab and the popup of its is running the same process.
I have change registry key TabProcGrowth to 20, to make sure every single tab run by its own process, but maybe it not work with popup.
sr for my bad english, any suggestion is welcome.
Thanks in advance.
update:
I have changed the way to develop my addon, so I change my question, too. (But any suggestion for the 1st question still very useful for me).
My new question still mention the "execScript" problem.
HOW to execute javascript with every individual tab of IE browser with TabProcGrowth = 0. I need this value set to 0 because I have the timer to request to the server every interval1 (ex: 60s). So if there are more than one processes of IE, the addon will send multi request to server at the sametime.
In my situation now, I set TabProcGrowth to 0. Open IE, open some tabs. Click the toolbar at the newest tab, it works, ofcourse!. But when I click toolbar at the old one, nothing happen. The script still be execute but it takes effect on the newest tab.
It's the big problem for me, resolve this problem, you guys save my life.

Categories