I have a back button that uses Response.redirect,
This opens up the page I want but in a new window instead of opening it up in the current window(refreshing to new page?)
As <a href= Target=_self would do ? I'm not using this as It need to be a button like the rest of the buttons.
VB.net
Please use j query script reference and use
window.open("foo.aspx");
Related
I am trying to write a code to be able to press a button on a website using VBA. This is the element I get by inspecting the website :
button class="btn btn-cta xs-liquid btn-progress pull-right l-margin-15-bottom" type="submit">verder.
There is no id for the element, I only get the class and type. How can I use these to be able to write an efficient code?
Thank you
If the page is static (it does not change), then you can use GetElementsByTagName or GetElementsByClassName, and take the element with the zero-based index i from that collection: .Document.GetElementsByClassName("btn btn-cta xs-liquid btn-progress pull-right l-margin-15-bottom")(i).
In case of more complicated scenarios I would recommend XPath or CSS search.
In web page,there are few tabs like CustomerAccountContact.
These tabs are inside SPAN html tag.
I have added the web element for Account in OR. When I try to highlight it works fine but when I try to click using Click method its not going to the Account tab.
If I take the abs_x and abs_y of the web element and try to click using mercury.devicereply object it works fine.
PFB, the html source code for accounts tab:
<a class="x-tab-right" onclick="return false;" href="#">
<em class="x-tab-left">
<span class="x-tab-strip-inner">
<span class="x-tab-strip-text ">
Account
</span>
</span>
</em>
</a>
Since the link has an onclick="return false;" this means that click events don't do anything and the application reacts to different events. Apparently these events aren't those that UFT fires when it simulates a Click event.
You have two options as I see it.
Find out what event the application is reacting to and fire that event in the test (instead of performing a click)
Use device replay, this can be done more simply than using the Mercury.DeviceReplay object as you're doing by changing the replay-type to device (as explained in this answer).
It is occurring because application is firing different event. Even fire event may not work in this case. Since it is already working with Mercury device replay it would be better for you to create and register it (RegisterUserFunc).
RegisterUserFunc "WebLink", "fLnkClick", "fLnkClick"
Use:
Before click method
Setting.WebPackage("ReplayType") = 2
After click method
Setting.WebPackage("ReplayType") = 1
If you set Replay Type = 2 then you are giving control to Mouse, which do the actions similar the way you do manually. So clicks, mouseover and other mouse related actions will work if normal QTP click fails.
Also we can use "Mercury.DeviceReplay" object for the implementing similar logic.
<div class="add" data-icon="'" ng-show="!editMode" ng-click="btnAdd()"> Add an Honor or Award </div>
Above is the html code for the button i am trying to click (Add an Honor or Award), but this button doesn't have an unique ID, and keeps on changing the xpath as the user adds multiple data.
Use css
[class='add'][ng-click='btnAdd()']
xpath is also another option
//div[contains(.,'Add an Honor or Award')]
Or,
//div[#class='add']
For test automation on a web app I am currently using Robot framework and the Selenium library. There comes the moment I want to click on a button and then I wait for an element to appear. Alas, the click, although recorded successful in the log, does not lead to the apparition of the element I wish. In fact it is as if the click never happened.
To click on the button, I retrieve it using xpath. Using Firepath I successfully verified that the element is unique and does exist but what it shows leads me to think I have found why the button is not clicked correctly
You can see in light blue the button I want to click on and wrapped with dotted line the zone detected by firepath.
Is it possible that the click is done next to the button instead on it ?
Here is the incriminated line :
Click Element xpath=(.//button[contains(#id,'editContract')])[1
Edit :
HTML of the page :
<button id="listContractTableForm:listContractTable:0:editContract" name="listContractTableForm:listContractTable:0:editContract" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" onclick="window.location.href='destinationPage?faces-redirect=true&contractEntityContractId=678'">
<span class="ui-button-icon-left ui-icon ui-c ui-icon-search"></span>
<span class="ui-button-text ui-c">ui-button</span>
</button>
Assuming you want the span with class containing ui-button-icon-left ui-icon ui-c ui-icon-search
//button[contains(#id,'listContractTableForm')]/span[contains(#class,'ui-icon-search')]
if you want the span with class="ui-button-text ui-c" simply change the class in the xpath
I am trying to test a web page using Selenium IDE. Am new to selenium.
The code is something like this.
<script src="type="text/javascript">
<script src="max.js" type="text/javascript">
<ul class="toolbar">
<li id="addTitle">
<span class="icon-add">Create New Title</span>
</li>
<li></li>
</ul>
When I click on 'Create New Title' - Selenium does not record anything. Please let me know if I need to provide any further information.
Thanks!
I have tried 'View Xpath'.
But 'View XPath' shows
id('addTitle')/x:span
Results from https://abc.xyz.com/ui/states/LisitTitles.ddx
But I want to add
https://abc.xyz.com/ui/states//ManageStates.ddx?action=add
which is for Create New Title button
I don't see https://abc.xyz.com/ui/states//ManageStates.ddx?action=add
anywhere in the page source code or Xpath.
In Page source I see:
document.location = ABC.PM.TITLE.builderURL + "?action=add";
Also how do I know whether it is Open/Click/etc commands I should be
using? Also does this have something to do with Pagination?
Thanks
You can add this manually by using xPath:
Command | click (or clickAndWait)
Target | //li[#id='addTitle']/span[#class='icon-add']
Value |
It will cause clicking an element containing the text 'Create New Title', as you see.
Open command is for openning a new web page.
Click command is for simulating a user clicking on an element.
On the selenium IDE window you can display all the available commands. You just have to click on the triangle above the "Find" button.
There is also a description for every command in the "Reference" tab
You can take a look on a screenshot here for more informations :
http://seleniumhq.org/docs/02_selenium_ide.html#ide-features#opening-the-ide