access login button in UFT - hp-uft

I am new to UFT. I am trying to automate one administrative page in my application. But after entering username and password, login button is not getting enabled.
But if am trying to replicate it manually, it is working fine.
Here are the couple of lines from script:
SystemUtil.Run "iexplore.exe","https://sl007670.dcm.allianz:12100/acce/"
Browser("Administration Console").Page("Administration Console").WebEdit("acce_LoginPane_username").Set "NLGPRBR"
Browser("Administration Console").Page("Administration Console").WebEdit("acce_LoginPane_password").Set "welcome.1"
Browser("Administration Console").Page("Administration Console").WebElement("Log In").click
Thanks,
Vinod

By default, UFT uses event replay type.
Sometimes this happens because what UFT does, doesn't fire the events required by the AUT (application under test) in order to enable other controls like in your scenario. I'd suggest switching replay type to mouse and then, set WebEdit values. For example:
Setting.WebPackage("ReplayType")=2 'mouse
Browser("Administration Console").Page("Administration Console").WebEdit("acce_LoginPane_username").Set "NLGPRBR"
Browser("Administration Console").Page("Administration Console").WebEdit("acce_LoginPane_password").Set "welcome.1"
Setting.WebPackage("ReplayType")=1 'event (original value)
Browser("Administration Console").Page("Administration Console").WebElement("Log In").click

Related

Capybara will not click button for Stripe SCA authentication

I cannot get Capybara to click on the SCA/3DS ‘Complete authentication’ button when running RSpec tests. Similar tests which do not trigger SCA pass just fine, and if I run VNC to view what Firefox is doing, the button is visible and I can click it myself in the browser.
My problem seems very similar to what’s discussed in the comments here, but the solutions do not work: I have tried changing the browser used, and flattening the iframe traversal.
Test code:
scenario "SCA required" do
create_payment_method(account, payment_method: "stripe", last_four: "1234")
visit "/billing"
click_on "Enter Card Payment"
within "#main-content" do
within_frame(find("iframe")) do # Stripe payment form is in an iframe.
find("input#Field-numberInput").set("4000002760003184") # SCA-required test card.
find("input#Field-expiryInput").set("1234")
find("input#Field-cvcInput").set("123")
find("input#Field-postalCodeInput").set("12345")
end
end
find("button#submit").click
# Stripe nests the popup in several layers of iframes.
stripe_frame = find("body > div > iframe") # Popup is prepended to the body element.
switch_to_frame(stripe_frame)
challenge_frame = find("iframe#challengeFrame")
switch_to_frame(challenge_frame)
fullscreen_frame = find("iframe.FullscreenFrame")
switch_to_frame(fullscreen_frame)
click_on "Complete authentication"
switch_to_frame(:top)
expect(page).to have_content "ends in 3184"
end
Is there some way to debug what Selenium is doing under the hood here? I don’t see any movement on the page when running click_on "Complete authentication", but if I click on the button myself in the Firefox instance being controlled by Selenium it does work.
Running click_on "Complete authentication" returns the element clicked, which appears to be the expected element when I drop into Pry and call native.dom_attribute("id").
I can see an error of some kind in the browser container’s logs:
1654078084345 Marionette WARN TimedPromise timed out after 500 ms: stacktrace:
TimedPromise/<#chrome://remote/content/marionette/sync.js:239:19
TimedPromise#chrome://remote/content/marionette/sync.js:224:10
interaction.flushEventLoop#chrome://remote/content/marionette/interaction.js:431:10
webdriverClickElement#chrome://remote/content/marionette/interaction.js:179:31
It’s a bit odd because it mentions #chrome but this is a headless Firefox instance.
Assuming no error is returned by the click_on call then I'm guessing the button is being clicked before it's ready to be clicked. You can test that by sleeping for a few seconds before calling 'click_on'/navigating through the frames. If that fixes it then you'd need to look at what changes on the button to indicate that the page has finished whatever work it's doing and the button is ready to be clicked.
I have solved this by clicking on the button directly with JavaScript:
execute_script(%Q{ document.querySelector("button#test-source-authorize-3ds").click() })
However, this does not in any way explain why click_on is not working, and if anything makes it more strange that it is not. If anyone has a better solution or a way to dig into why Capybara/Selenium are failing then that would be welcome.

Not able to know when user is identified as a bot in google invisible captcha on client side

I am following Programmatically invoke challenge process for identifying a user as human or bot.
below is my captcha div in html.
<div class="g-recaptcha"
data-sitekey="<site_key>"
data-callback="onSubmit"
data-size="invisible">
</div>
and i have data callback function in my html script tag:
var onSubmit = function(token){
// do next processing with token
}
data callback gets invoked every time when google identifies a user as human successfully.
it does not get invoked when google identifies a user as a bot.
but i want to know when google identifies user a bot in above similar way on clicking a button?
because when i click on a button, i programmatically invoke challenge by grecaptcha.execute() so this happens:
1) if user is validated as human , data-callback is called and i do my next processing with token.but
2) if user is not validated as human, data-callback is not called and nothing happens on click and i stay on same page.
i expect acknowledgment here in second case so that i can decide further processing.
please help me in this.

stop execution till the page load OR some time (ms) in xamarin

I am a beginner in Xamarin and learning to write test using NUnit framework. I am testing an app where am getting some problems in writing test cases some of them i solved but i need some help in solving other issues that am facing. Referring the official Xamarin documentation and learning the scripts but i am not able to find solution for the below issues.
When i use repl() and tree method for a screen of the app not able to get the elements where as if i use uiautomatorviewver then am getting all the elements in the screen. so to tap these elements i used TapCoordinates method to click on the elements and its working fine.
My question is why am not getting the elements in UI if i use repl and tree commands?
If we use tapcoordinates Is the script works for scalability i.e for the other screen sizes? If its not works for other screen sizes then how to solve this problem?
I have script that has to wait for some time before executing a command Is there any method to stop execution till some Micro Seconds?
//Click on Next buttons available at first four pages
app.TapCoordinates(752, 1650);
app.TapCoordinates(752, 1650);
app.TapCoordinates(752, 1650);
app.TapCoordinates(752, 1650);
//Click on Launch Button to move to I agree checkbox
app.TapCoordinates(752, 1650);
// Click I agree button
app.TapCoordinates(772, 1685);
// Click Login Button on the same screen as I agree checkbox
app.TapCoordinates(315, 1240);
//Entering user name
app.EnterText(e => e.Css("input#cwsUID"), "qaqa68");
//Entering password
app.EnterText(e => e.Css("input#cwsPwd"), "Harmony1");
//Click Login button
app.Tap(e => e.Css("input#submitButton"));
In the above script i want to delay execution between the steps. The problem is its executing the scripts when i ran on a device after the first line execution its trying to execute second line but till then the second page is not loaded so i have to stop execution till that next page is loaded or some MS.
You can use app.WaitForElement() and wait for an element that exists on the second page, and the test will pause until that page is loaded.

Is waiting needed in Capybara for non DOM-altering Javascript?

From what I understand of Capybara's autowait feature, it waits for the DOM to change, so I guess it's waiting for all AJAX requests to complete and/or the main frame to finish loading.
I have a test case in which I need to:
fill in a field (name_1)
click a save button
check the object is saved properly
When I fill in the name_1 field, some JS from the app I'm testing fills in other mandatory fields automatically (notably, link_rewrite_1).
Problem is, when I check for the other field to be actually filled, it is not!
I'm thinking the JS that fills the other fields has not had time to complete when the test is run, and the test doesn't wait since there is no AJAX call pending.
Here is the relevant code snippet:
fill_in 'name_1', :with => 'Bob' #some javascript should run and fill link_rewrite_1
find('#link-Seo').click
page.should_not have_field('link_rewrite_1', with: "")
In plain English, I fill in name_1 and expect link_rewrite_1 not to be empty.
I've tried to insert a sleep 1 before the last check, but it doesn't change anything. Since sleep will pause the execution of the entire ruby thread, maybe it just freezes webkit and changes nothing, I don't know.
Am I right in suspecting a timing issue or is there likely something else going on here?
After further debugging, it seems like it is a driver issue. Capybara-webkit just doesn't execute my JS correctly. Works fine with selenium-webdriver.

My Asp.Net Form data is not being submitted properly by Selenium 2 (Webdriver)

So I have written a test which populates a form, saves (in the admin tool), and then publishes.
However, my form is being lost between the save click and the publish click. I would show what the form looks like in HTML, but its pretty huge (like 20-30 fields)
In psuedo code, filling out the form looks like this:
1) Fill in form using dropdowns
2) Hit the save button - saves all form data
3) Hit the publish button
When I pause the script to see what is happening within selenium, I see the form properly being populated. I then see the Save button properly being clicked. When I pause the screen before hitting publish, I see that the content I have saved after clicking the save button was lost or is in the wrong fields.
When I do this manually, it works correctly. I know selenium submits forms differently than the standard user, however, is there anything I can do on my end to make sure that form is being submitted properly?
What does the Save button actually do? Is it Javascript, or a simple ` button?
Are you using the C# interface to Selenium webdriver? You probably have code that looks something like this:
FillInForm();
selenium.click(By.CssSelector("input[value='Save']"));
selenium.click(By.CssSelector("input[value='Publish']"));
Have you tried inserting, between save and publish, lines like the following:
// further up: By saveButton = ...
// By formField = ...
selenium.click(saveButton);
var formField = selenium.FindElement(formField);
Assert.That(formField.GetAttribute("value")
.contains("The text you typed into the form")
);
The point here being to check that save really is doing what it says on the tin. Generally, when you ask the WebDriver to "click" on a button, it does do exactly (more or less) what the user does. Alternatively, you can inject some javascript to force the form to submit - but then you're explicitly not testing what the user actually does (but you might find it's closer to what you experience).

Resources