UFT does not recognize Java Security Warning - hp-uft

After moving on Java 1.8 there is a security warning showing on starting web-start application.
UFT can see all objects of this Java dialog by object spy. So I have coded message checking and confirmation block:
If JavaDialog("label:=Security Warning").Exist(40) Then
JavaDialog("label:=Security Warning").JavaCheckBox("text:=I accept the risk and want to run this application\.").Set True
JavaDialog("label:=Security Warning").JavaButton("label:=Run")
End If
But during test execution even 40-seconds waiting for existance of JavaDialog("label:=Security Warning") returns False right at the moment, without waiting at all.
What is the reason for this behaviour? How to fix?

It might be throwing an error in line 1 (line with if statment) in the background. and because of 'proceed to next step' option in File > Settings > Run, UFT is proceeding to next step and returning False to you.
Try moving Exist() outside the if statement.
strExist = JavaDialog("label:=Security Warning").Exist(40)
If strExist Then
JavaDialog("label:=Security Warning").JavaCheckBox("text:=I accept the risk and want to run this application\.").Set True
JavaDialog("label:=Security Warning").JavaButton("label:=Run")
End If

If UFT is not waiting for 40 seconds, then there might be an error generated in that line.
I am able to execute the below code without any issues
if JavaDialog("label:=Security Information").Exist(40) then
Msgbox "Test"
End If
What you can do to debug this is
1) Check the UFT's run result report, that will have the error generated by UFT. That will help you in identification of issues.
2) As Yogesh suggested, turn off any error settings and comment any On error resume next statements in your script. This will make sure that UFT shows you the error instead of skipping the line.

Related

Azure-Pipelines - Script that requires Ctrl+C or Typing 'y' to end

I'm using Azure-Pipelines for my CI Pipeline running on windows-2019. One of my cmd scripts generates output report files and continues to run until either Ctrl+C is pressed, or 'y' is typed. How is this done? If I add another script after this one as 'y', it will never reach because the previous command will never terminate.
In the meantime, I added the "timeoutInMinutes" param to the script so it timeouts in a minute, but this still causes a task error which is not ideal.
Does anyone have any ideas on how I can end the first script once it's complete? (It takes about 5 seconds to complete the necessary task)
You can't. it is impossible to enter a user input during Azure Pipeline.
You must edit your script to not finish and wait for user input.

test continues to run in cypress runner after it fails, does not timeout

enter image description here
I have the following test in cypress:
cy.visit('/main.html')
cy.get('#homeTitle').contains('Welcome')
this passes.
If I change the contains value to "Welcome2" test should fail, and it fails in the runner, but the timer displayed continues to run, and it will not proceed to next test.
Seems like it doesn't time out or something.
Are you trying to test that the element with id #homeTitle should contain the text message 'welcome' ? If so try this:
cy.get('#homeTitle').should('contain','welcome');
I don't quite understand your issue, but I will look harder.

How to find out whether a webpage is opened or not using VBScript

I tried with this below code to find out whether the webpage is opened or not, but this code is not working for me. System is just flashing only the first opened webpage URL.
surl ="http://www.google.com/"
set shapp=createobject("shell.application")
For Each owin In shapp.Windows
msgbox owin.document.location.href
if Instr(1,owin.document.location.href,surl)>0 then
msgbox "Window opened"
end if
Next
set shapp=Nothing
The error message is:
Script execution time was exceeded on script "D:\ie_open.vbs" Script execution was terminated
Given the error message "Script execution time was exceeded ...", the problem may be caused by a too small time out. See here. Use something like:
cscript //T:0 "D:\ie_open.vbs"
to test this assumption.
A default timeout value can be stored in the registry in either of the following locations:
HKCU\Software\Microsoft\Windows Script Host\Settings (per user)
HKLM\Software\Microsoft\Windows Script Host\Settings (global)
Deleting the Timeout value removes the preset timeout.
Instead of owin.document.location.href Use oWin.locationURL

Ruby/Selenium WebDriver - Pausing test and waiting for user input, i.e. user inputs captcha

I'm using the Selenium WebDriver and Ruby to perform some automation and I ran into a problem of a captcha around step 3 of a 5 step process.
I'm throwing all the automation in a rake script so I'm wondering is there a command to pause or break the script running temporarily until I enter data into the captcha and then continue running on the next page.
To build on seleniumnewbie's answer and assuming that you have access to the console the script is running on:
print "Enter Captcha"
captchaTxt = gets.chomp
yourCaptchaInputWebdriverElement.send_keys captchaTxt
If you just want to pause and enter the captcha in your browser, you can just have it prompt at the console to do that very thing and it'll just sit there.
print "Enter the captcha in your browser"
gets
You could also set the implicit wait to decently long period of time so that Selenium would automatically see the next page and move out. However, this would leave the important Captcha step (for documenting / processes sake) out of your test unless you're pretty anal with your commenting.
Since this is an actively participating test requiring user input I would say that making the tester press "enter" on the console is the way to go.
Since you are writing the test in a script, all you need to do is add a sleep in your test i.e. 'sleep 100' for example.
However, it is bad to add arbitrary sleeps in tests. You can also do something like "Wait for title 'foo'" where 'foo' is the title of the page in Step 4. It need not be title, it can be anything, but you get the idea. Wait for something semantic which indicates that step 3 is done and step 4 is ready to start.
This way, its more targeted wait.
This has been implemented in JAVA, but similar technique.Your solution could be found here

Why are my delayed_job jobs re-running even though I tell them not to?

I have this in my initializer:
Delayed::Job.const_set( "MAX_ATTEMPTS", 1 )
However, my jobs are still re-running after failure, seemingly completely ignoring this setting.
What might be going on?
more info
Here's what I'm observing: jobs with a populated "last error" field and an "attempts" number of more than 1 (10+).
I've discovered I was reading the old/wrong wiki. The correct way to set this is
Delayed::Worker.max_attempts = 1
Check your dbms table "delayed_jobs" for records (jobs) that still exist after the job "fails". The job will be re-run if the record is still there. -- If it shows that the "attempts" is non-zero then you know that your constant setting isn't working right.
Another guess is that the job's "failure," for some reason, is not being caught by DelayedJob. -- In that case, the "attempts" would still be at 0.
Debug by examining the delayed_job/lib/delayed/job.rb file. Esp the self.workoff method when one of your jobs "fail"
Added #John, I don't use MAX_ATTEMPTS. To debug, look in the gem to see where it is used. Sounds like the problem is that the job is being handled in the normal way rather than limiting attempts to 1. Use the debugger or a logging stmt to ensure that your MAX_ATTEMPTS setting is getting through.
Remember that the DelayedJobs jobs runner is not a full Rails program. So it could be that your initializer setting is not being run. Look into the script you're using to run the jobs runner.

Resources