Page recognition is delayed in UFT 12.5 - hp-uft

I am able to identify browser but page identification is delayed in UFT 12.5. AS a result all the operations under the object are getting delayed.

use implicit/explicit wait.. sample code
For I=1 to 100
IF Page.exist(1) then
exit for
else
wait (1)
end if
next

Related

How to set a default wait for Alert with Capyabara?

In my code I don't want to use sleep. How do I use wait_until.
########### my code ###############33
btn_logout.click
sleep 3
page.driver.browser.switch_to.alert.accept
This should work
accept_alert do
btn_logout.click
end
It'll wait for the modal as long as the max wait time that is set for Capybara.

SAP Script Recording and Playback - Cumulative data

If I am using the Script Recording and Playback feature on same transaction for instance ME25, multiple times, I am getting cumulative data as part of multiple scripts rather than incremental data.
Explanation :
If I open ME25 details and enter "100-310" as Material and "Ball Bearing" as Short Text and stop the recording, I get the following script, which is expected behavior.
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/ctxtEBAN-MATNR[3,0]").text = "100-310"
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/txtEBAN-TXZ01[4,0]").text = "Ball Bearing"
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/txtEBAN-TXZ01[4,0]").setFocus
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/txtEBAN-TXZ01[4,0]").caretPosition = 12
After this, I restart the recording and type Qty Requested as "100" and delivery date as "21.04.2021" and stop the recording. I get the following script:
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/ctxtEBAN-MATNR[3,0]").text = "100-310"
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/txtEBAN-TXZ01[4,0]").text = "Ball Bearing"
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/txtEBAN-MENGE[5,0]").text = "100"
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/ctxtRM06B-EEIND[8,0]").text = "21.04.2021"
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/ctxtEBAN-EKGRP[9,0]").setFocus
session.findById("wnd[0]/usr/tblSAPMM06BTC_0106/ctxtEBAN-EKGRP[9,0]").caretPosition = 0
Instead of getting the incremental part that I typed for the second recording instance, I am getting complete script. Is there a way to achieve incremental scripts?
I can reproduce in my SAP GUI 7.60 (whatever screen it is; whatever kind of field it is, I can reproduce even with very simple fields like in a Selection Screen).
It seems that it happens all the time, even if you write your own recorder (a VBS script which mainly uses session.record = True + event handlers). It's due to the fact that SAP GUI sends all the screen events (i.e. the user actions) since the screen was entered, when the user presses a button, a function key, closes a window, or stops the SAP GUI Recorder.
If you write your own recorder, I guess you can save the screen contents when you start the recorder, and when the "change" events occur you may ignore those ones where the new field value has not changed since the recorder started. But that's a lot of work.
I think that it's far more easy to append manually the last lines of the last script to the initial script.

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

vbs automatic script

Is it possible to create a vbs script that call itself when a certain pc action is activated,lets say opening up a browser?A replica would be someone opens up a browser,then the vbs listens to this activity and runs itself or calls another vbs script?
Jimmy, if you want the code to be executed when a browser window is opened, consider this code :
Set obj0 = createobject("wscript.shell")
Dim Count
Count = 0
Do while count = 0
If obj0.appactivate("browserwindowtitle") then
-------do something----
----
----
Count = 1
Else
Wscript.sleep(10000)
Count = 0
End if
Loop
Set obj0 = nothing
The above code will check if the window having the title "browserwindowtitle" is open or not. If it is open, it will execute the desired action. If the window is not open, script will wait for 10 seconds and try again.
After writing the script go to control panel-> scheduled tasks and add the script as scheduled on startup. When you do this, the script will start executing when your PC turns on and will keep on checking if the browser window is open or not.
There will be easier ways to do this, others might be able to help.
You may want to give System Scheduler a try.
http://www.splinterware.com/products/wincron.htm

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

Resources