How to pass captcha image text in textbox on runtime?

How to pass captcha image text in textbox on runtime

Hello,

can you help me with captcha as well? i have a user registration flow that ends to a captcha image (not text) verification, meaning that it shows you some images and asks you to e.g. click the ones that show a car etc.

What can i do about this type of captcha in order to automate the user registration? Is there a way to handle it apart from asking developers to disable it in the testing environment?

Thank you in advance,

NB

Hi Vinh Nguyen, Thanks for answering my question.

The purpose of captcha to prevent unauthorized registration.

What I am asking if any keyword available to get input from user through popup, when test case running.

Its already available in selenium ide, get input from user when script is running. So that user type in popup by seeing the image. Same passed to text field of captcha.

Same available in katalon?

Hi there,

Yes Katalon Studio can handle this. You need to add ‘wait’ step into your test script so that execution will wait in a short amount of time for you to input on popup, and then in next steps it can use your input

Example:

'Wait 10 seconds to let users input on captcha field'

WebUI.delay(10)

'Get Text from Captcha field after user input'

captchaText = WebUI.getText(findTestObject('Page_DemoAUT/txt_Captcha'))

Thanks

Hi there,

Captcha is randomized everytime and it’s a method to prevent automation registration. So you can’t automate it as well as pass captcha image text in the textbox.

Thanks

Vinh Nguyen said:

Hi there,

Yes Katalon Studio can handle this. You need to add ‘wait’ step into your test script so that execution will wait in a short amount of time for you to input on popup, and then in next steps it can use your input

Example:

'Wait 10 seconds to let users input on captcha field'

WebUI.delay(10)

'Get Text from Captcha field after user input'

captchaText = WebUI.getText(findTestObject('Page_DemoAUT/txt_Captcha'))

Thanks

‘Page_DemoAUT/txt_Captcha’ what does mean that code

Sanowar Alam said:

‘Page_DemoAUT/txt_Captcha’ what does mean that code

That’s just the test object from the object repository, view the script view documentation for more details

hi all

help me please…

if i want to wait for finish captcha without timeout, and just use to send key (pressing in keyboard CTRL+X) to continue another step , is it possible to next step without time delay ?

note :
after finish captcha i just pressing keyboard CTRL+X, then katalon run again to next step

jerry said:

hi all

help me please…

if i want to wait for finish captcha without timeout, and just use to send key (pressing in keyboard CTRL+X) to continue another step , is it possible to next step without time delay ?

note :
after finish captcha i just pressing keyboard CTRL+X, then katalon run again to next step

Dear jerry, I did not find solution of your request, which is also mine. I decided to create one solution, which will be waiting for user input, and when input will be typed, test will continue. Maybe my approach will be helpful also for you.

I have created new testcase with name “WaitForVerificationCaptchaInput”. Its content is:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpointimport static com.kms.katalon.core.testcase.TestCaseFactory.findTestCaseimport static com.kms.katalon.core.testdata.TestDataFactory.findTestDataimport static com.kms.katalon.core.testobject.ObjectRepository.findTestObjectimport com.kms.katalon.core.checkpoint.Checkpoint as Checkpointimport com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactoryimport com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywordsimport com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobileimport com.kms.katalon.core.model.FailureHandling as FailureHandlingimport com.kms.katalon.core.testcase.TestCase as TestCaseimport com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactoryimport com.kms.katalon.core.testdata.TestData as TestDataimport com.kms.katalon.core.testdata.TestDataFactory as TestDataFactoryimport com.kms.katalon.core.testobject.ObjectRepository as ObjectRepositoryimport com.kms.katalon.core.testobject.TestObject as TestObjectimport com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywordsimport com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywordsimport com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUIimport internal.GlobalVariable as GlobalVariableInteger captchaInputLength = 5String captchaTestObjectID = "Login/input_Captcha";Boolean isVerificationInputExisting = WebUI.verifyElementPresent(findTestObject(captchaTestObjectID), 0)if(isVerificationInputExisting == true){	//object is existing and I can continue		Boolean isCaptchaTextWriten = false	while (isCaptchaTextWriten == false) {		//Captcha text is not written so I have to wait		String captchaInput = WebUI.getAttribute(findTestObject(captchaTestObjectID),'value')			println('Comparing captcha string "'+captchaInput+'"')		if (captchaInput.length() >= captchaInputLength) {			//Captcha length is as expected. I can remember this good news			isCaptchaTextWriten = true		}				println('Waiting for user input 3 sec.')			WebUI.delay(3)	}	//Captcha text length is as expected. Well done}

This solution will wait (without timeout) for user until string is typed by user to captcha input

You can use this testcase inside some main testcases. For example :

WebUI.openBrowser('')WebUI.navigateToUrl('https://www.testingsitewithcaptcha.com/')WebUI.setText(findTestObject('Login/input_Login'), 'LoginName')WebUI.setText(findTestObject('Login/input_Password'), 'TopSecretPassword')WebUI.callTestCase(findTestCase('Login/WaitForVerificationCaptchaInput'), [:], FailureHandling.STOP_ON_FAILURE)WebUI.click(findTestObject('Login/span_submitbutton'))WebUI.closeBrowser()

It works for me :slight_smile: Good luck.

to all testers trying to avoid captcha - you cannot avoid it.
To automate tests you need to have environment where you will ask developers to turn off captcha or redirect it to dummy captcha. They can do that (even on google image captcha)

You can try to guess the captcha by selecting random squares in hopes of 1 in every 10,000 working?

How can we store data from web in a variable(Say a text or a string) and use the stored data as input in same script?

like:

def x = WebUI.getText(ElementYouWant)
WebUI.setText(OtherObject, x)

some selenium tests or scrapers will create an integration using a 3rd party such as https://2captcha.com/. They cost $, but are very cheap. I think they have humans manually analyze images and their system will provide solutions to users. This is a way to make sure that your captcha is not bypassed using selenium.

Hi guys, I am experiencing captcha issues while running an automated test on the katalon studio.
After login button is clicked the website is supposed to redirect to the account page. but image captcha appears as I am identified as a robot.

I try to use the “delay” or “wait” steps. However, the image captcha keeps refreshing and it never ends lol…so frustrating…
How can I solve this issues, then continue the test.

Thxxx.
04%20PM

Hello,
did you read this thread before posting?

Hi @Andrej_Podhajsky
I also thought the captcha should look ugly.
But I had no idea to ask the Dev team to disable the captcha feature in the test environment.

Thank you for this idea and it proves that we are professional in reasoning.
:smiling_face_with_three_hearts: :heart_decoration:

1 Like