I'm trying to just open http://espn.go.com/ and then click on the "NBA" tab using TestComplete.
Could someone tell me how to do this to get me started?
Thanks!
In the example below, you need a unique property name and value of the tab you want to click to be able to find it on the page. You can find this by clicking the tab using the Object Spy tool in test complete.
function nbaTest(){
var nbaTab;
//open browser at espn page
Browsers.Item("iexplore").Run("http://espn.go.com");
//search page for nba tab using a unique property name and corresponding property value of the nba tab
nbaTab = Sys.browser('iexplore').page("*").Find(propertyName,propertyValue,"1000","TRUE");
if (nbaTab.exists){
nbaTab.click();
}
else{
Log.Warning("NBA tab not found");
return;
}
}
I've tried using TestComplete' Recording feature - the script looks reliable. This is what was recorded:
var page;
Browsers.Item(btIExplorer).Navigate("http://espn.go.com/");
page = Aliases.browser.Page("http://espn.go.com/");
page.Panel(1).Panel("content").Panel("nav_wrapper").Panel("nav_wrapper_container").Panel("nav_main").Link("lpos_sitenavdefault_lid_sitenav_nba").Click();
Keyword test to open http://espn.go.com/ and then click on the "NBA" tab:
Steps:
Run TestComplete (I'm using version 10)
Launch the recording (By clicking "Record New Test" or "Append to Test")
Open IE and type the URL http://espn.go.com/ on address bar -> Click NBA tab -> Close the browser
Stop recording and see the KeywordTest you recorded in TestComplete IDE
My KeywordTest I recorded was as below:
Run Browser Parametrized (Internet Explorer, "", pX64) "http://espn.go.com/", ... Launches the specified browser and opens the specified URL in it.
pageEspnTheWorldwideLeaderInSpor Wait Waits until the browser loads the page and is ready to accept user input.
linkTennisM HoverMouse 0, 0 Moves the mouse pointer over the 'linkTennisM' control.
pageEspnTheWorldwideLeaderInSpor Wait Waits until the browser loads the page and is ready to accept user input.
panelModContainerModTabsModNoFoo ClickTab "NBA" Selects the 'NBA' tab of the 'panelModContainerModTabsModNoFoo' tab control.
linkNba HoverMouse 8, 6 Moves the mouse pointer over the 'linkNba' control.
panelHeader HoverMouse 658, 25 Moves the mouse pointer over the 'panelHeader' control.
ToolbarWindow32 ClickItemXY "&File", 16, 8, false Clicks at point (16, 8) of the '&File' item of the 'ToolbarWindow32' toolbar.
PopupMenu Click "Exit" Moves the mouse cursor to the menu item specified and then simulates a single click.
Not sure if this will help but you might be able to automate the step of opening your browser as well.
I use:
Call Sys.OleObject("WScript.Shell").Exec("cmd /c start /MAX iexplore ""http://espn.go.com""")
From there, you can automate the rest as usual (might need to wait for the page to load here as well).
Related
I have a pop up window containing a script in its head. And this script should be triggered by click on the window button. But after click on this button the script does not run. Could you suggest the reason?
Steps to reproduce:
Click on a button in the main window.
Child window containing a simple form is open.
Move to the child window, fill in the form fields and click on submit button.
Expected result: The click triggers a script located in the child window head. The script process the form and submit it.
Actual result: an error arises: "submitMyForm is not defined" (reference: submitMyForm() is a method containing in the script mentioned above).
So the problem is that the child window form fields can be populated and form button can be clicked but the script bounded to the button by means of the link <a href="javascript:submitMyForm();"> does not work as the function submitMyForm() is not found. Obviously the reason of the test failure is stubbing the child window which is performed to prevent having 2 windows at the same time. After this the child window is opening in the same browser tab as Cypress is not able to work with 2 windows open in the same time. But in this case the script stops working neither from the test nor by performing the click manually.
Here is a code snippet from the Cypress test:
const pop_url = `/dir1/dir2/file.php?id=${sectionId}`; // Here is a new window URL
cy.window().then( win => {
const stub = cy.stub(win, 'open').as('windowopen');
newSurveySectionListObj.AddNewBtnClick(); // Triggers form opening in the new window
cy.get('#windowopen').should('be.called.with', pop_url);
cy.window().then( $win => {
$win.location.href = pop_url
newSurveySectionListObj.typeDropdownSelect('Matrix'); // works fine
newSurveySectionListObj.modalDescriptionFldType('Cypress test string'); // works fine
newSurveySectionListObj.responseTypeDropdownSelect('Checkbox'); // works fine
cy.get('a[href="javascript:submitMyForm();"]').click(); // Does not work despite the button is clicked. An error "submitMyForm is // not defined" arises
});
});
You are going beyond what Cypress is capable of/designed for.
I would question why you are using a separate window in your app? You will run afoul of pop-up blockers that will prevent the new window being opened anyway. A percentage of users won't be able to work it out.
There are 2 approaches to this:
Use a modal dialog to achieve this (not great on mobile)
Use another route/page to display your form, return to the prev page when done
These have the advantage that they won't break with pop-up blockers, and your Cypress tests will work, as they are still in the same window.
I am a newbie in Xlib world. In my project,I want to share my window to another via Remote desktop protocol, but they only saw content of window and didn't see anything if click on menu item of window. I used XGetImage to get data of specifies window. But If that window contain dialog ( see image here) I couldn't get data of dialog .
I use freeRDP source code, I modify in X11_shadow.c
function:
int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem){
...
image = XGetImage(subsystem->display, 58720435, 0, 0, surface->width,
surface->height, AllPlanes,ZPixmap); //with 58720435 is window id of chrome
... }
In my opinion, the most important here is how can I get data of dialog in Window. I have a solution :
1. get window id of that dialog ( I am not sure the dialog has owner Window ID)
2. Use XGetImage get data of that dialog.
But It's not working.
I works on Linux environment.
Are there any solutions for my problems?
Thank you very much
I am very new beginner with VB6 and I hope I explain the things right
I want to create form with 2 buttons (the buttons are located on the top form position )
So each button will switch to other form/window/frame
For example
The first button will show window 1 (there I can set only parameters)
The second button will show window 2 (there I can set only IP address)
Please advice if we can do that by VB6 ?
And if yes how to do that ( step by step )
Remark - Similar example but with multiple windows in the same form is the system properties ( right click on my computer and properties ) , the we can see each button will view different window
Create a form with 2 buttons, Command1 and Command2.
On this form, create 2 frames, Frame1 and Frame2. hide Frame2 and make sure to line up both framesso that they are of the same size and located right on top of each other (Top, Left, Width and Height properties must be the same)
Now put this code in:
Private Sub Command1_Click()
Frame1.Visible = True
Frame2.Visible = False
End Sub
Private Sub Command2_Click()
Frame1.Visible = False
Frame2.Visible = True
End Sub
Now each the first button shows the first frame while hiding the 2nd. The second button hides the first frame and shows the seconds. I think this is the simplest way to implement your task.
PS: don't forget to name your objects properly, it's not a good idea to have default names like Command1 or Frame2 - should be more descriptive than that.
It sounds like you are asking about the tabbed dialog control. To use a tabbed dialog control in VB6:
Click Project -> Components
Scroll down to "Microsoft Tabbed Dialog Control 6.0" and select it.
Click the Apply button.
You should notice a new control in the component tool box. If you do not see the toolbox, click View -> ToolBox. This is the same area of the IDE where you first click to add a button to a form. The tabbed dialog control looks like the top tab of several file folders. When you hover your mouse over the control in the toolbox, you will see a tool tip text of "SSTab". Click this control and then draw a rectangle on your form.
By default, this will add a tabbed dialog control with 3 tabs, but you can change this in the properties window. You can now create any control on top of a tab of the tabbed dialog control and interact with the control exactly the same way you would if the control was placed on the form itself.
What you want is called an MDI Form. It's a form that contains other forms.
You can find a full tutorial on them here, but here's the gist of what you want to do:
Set the "MDIChild" property of all your subforms you want to use to True. Disable their minimize, maximize, and resize functions as well.
Create an MDIForm. Disable its AutoShowChildren property.
Add a toolbar to the MDIForm. Add buttons to the toolbar corresponding to the forms you'll be switching between.
Implement each button's click event, to create child form as expected (or switch to an existing one).
I would like to know if it's possible to simulate the process: Right click on an image -> Click on "Save image as.." on the popup menu -> save the image in local.
I tried CaptureBitmap() function, but the result is just a screenshot taken by QTP, not the same image file obtained as the procedure above.
Are there other ways? Many thanks in advance.
Allen
I suppose it depends what you want to do. If you want to compare the bitmap then the CaptureBitmap options should work. If you want to compare the path to the image you can use Image("x").GetROProperty("src").
If you really want to save the src image file then unfortunately QTP doesn't supply a way to interact with the browser's context menu. You can try to use some third-party mechanism to download the image from the src URL (e.g. wget).
Edit: I just had another thought, I'm not at work so I can't verify that it will work but I'm pretty sure it will.
First cause the context menu to appear, in order to do this you have to change the replay mode to device and run a RightClick operation.
replayType = Setting.WebPackage("ReplayType") ' Store old replay mode
Setting.WebPackage("ReplayType") = 2 ' change to device replay mode
Browser("b").Page("p").Image("I").RightClick
Setting.WebPackage("ReplayType") = replayType ' Revert to old mode
Then send the letter v to the browser which will select the Save menu item (on both IE and Firefox) by using the device replay object
Set deviceReplay = CreateObject( “Mercury.DeviceReplay” )
deviceReplay.SendString "v"
Now interact with the save dialog as a usual Win32 control.
Moral: Never underestimate what QTP will let you do if you try hard enough
I'm using Watir-webdriver and I was wondering if there was a good way to check if a new window opens. I've googled around a bit and couldn't find anything though it feels like there should be an easy answer.
I have a printer friendly link and I want to test that the link opens in a new window or tab and I would like to test this with ie, firefox, chrome and safari if possible.
Thanks!
You can check the number of windows:
browser.windows.size
or check if a specific window exists:
browser.window(:title => "foo").exists?
More examples in the specs.
You can also use index based browser window checking where you need to worry about index only and it follows zero based index ordering. So, the default window is of index: 0 and if a new window opens it will be of index: 1, the next will be of index: 2 and so on.
To check first child window if you want to test that the link opens in a new window ,
browser.window(index: 1).exists?
Or to work inside this window,
browser.window(index: 1).use do
# do scripting here
end