I was working with Sikuli for desktop application like notepad,
but want to know like can I open new tab in browser using Sikuli?
Yes, using Sikuli you can also automate browser. Take images of required web elements (Open new tab button in your case) and stimulate click action using Sikuli APIs.
Yes, you can use Sikuli for web testing.
In this code example, you can use sikuli app to: open browser --> New tab --> Give a like on a webpage (UTAD in this case):
click("mozilla_icon.png")
click("nova_aba.png")
click("endereco.png")
paste("www.utad.pt")
type(Key.ENTER)
wait(8)
click("like_btt.png")
wait(5)
Images of sikuli code:
yes you can use sikuli for performing open tab first take the image of new tab control like in case of FF https://drive.google.com/file/d/0B09BIsDTY_AuZFpMWko1U3BFc0E/view?usp=sharing .Save this image on you local machine. But make sure that image which is used for reference is visible on screen.Call the function mentioned below by and give it Absolute path to above mentioned image.
//provide absolute path in img
public void click_Image(String img)
{
s = new DesktopScreenRegion();
target = new ImageTarget(new File(img));
r = s.find(target);
// Create a mouse object
mouse = new DesktopMouse();
// Use the mouse object to click on the center of the target region
mouse.click(r.getCenter());
}
Related
I am new to the Sikuli API and I am using the Sikuli-java-jar file. I want to successfully click on a desktop element using the screen and pattern classes.
So I was trying to create an automation script to install software.
I am able to successfully launch the installer but not able to click on the Next Button present in the pop-up window.
I am not getting any error, it is just that clicking on the image fails.
appInstaller("E:\\Sikulimages\\tc.png");
appInstallers("E:\\Sikulimages\\next.png");
public static void appInstaller(String path) throws FindFailed{
s=new Screen();
img=new Pattern(path);
s.exists(path);
s.wait(img,2000);
s.doubleClick(img);
}
public static void appInstallers(String path) throws FindFailed, InterruptedException{
s=new Screen();
img=new Pattern(path);
s.click(img);
}
I think that the reason is that default Similarity (0.7) is insufficient for small buttons and text.
Sikuli has public class Settings ,
which hosts public static double MinSimilarity = 0.7;
That value is good enough for most image recognition, but it fails for small texts. To get small text clicked, you need to raise similarity for particular pattern, or, like I do, make Settings.MinSimilarity = 0.9;
Sometimes even 0.9 is not enough to recognize small text, well, then try 0.95 , it is usually what helps to pinpoint even smallest texts.
In addition to RPWheeler's answer, if there is something right next to your target image that will appear the same way every time, you can also take a bigger screen clip and then tell Sikuli which part of that bigger image to click on.
For example: if your "Next" button is part of a row of buttons, take the screen clip to include the whole row. Then, in the IDE, double click on the image, and go to the "Target Offset" tab. Here, you'll see an example of your image, and and you click on the part of the image you want Sikuli to click on. -- the default is always the center of the rectangle, but you can change it with the target offset.
You can accomplish the same thing in code like this
t = find(yourImage).targetOffset(dx,dy)
click(t)
where dx and dy are a positive or negative number of pixels away from the center point of the rectangle.
For installing application you need admin rights. So For running any task that require admin rights you need to run sikuli in admin mode. So right click on runSikulixcmd.bat and select Run as administrator for launching the Sikuli and then run the test.
If you are running the test from command prompt run it in admin command prompt.
I used Google map and visited a location and saved it as an html page by this I am able to view that location in future also with zoom functionality. Is it possible to save that location(map) in .pdf format instead of html format with zooming capability.
If yes how and if no then please answer why.
If you go to print that html file, the print dialog will pop up with the default printer. Click 'change' under the printer and choose 'Save as PDF'. You can zoom a pdf in adobe reader.
or (the long way)
Launch InDesign and create a new A4 landscape document. Now press F (Frame tool) on your keyboard and drag a frame with a size you wish to have for the map.
Go to Workspace settings (top right corner of InDesign) and change it to interactive for PDF. Go to Window → Interactive → Buttons. In InDesign you can create buttons very easily. Create any object and then right click and select Interactive - Convert to button.
To import a Google map to flash you need to download Google Map Component - map_1_18.swc.
In Windows 7 navigate to C:Program Files (x86)AdobeAdobe Flash CS6CommonConfigurationComponents. Then create a new folder there and name it Google. Store the .swc file there and then go to this page and follow the instruction to get the API key and save it. Your Flash is now set up to supports Google maps API.
Open the Components panel by pressing CTRL + F7 or click Window → Components in the menu. You should see the Google map library there. Drag and drop it to the Library panel.
Go to Layer panel in timeline and call it e.g. gmap. Open the Action panel (or Press F9) Windows → Actions. Now put there the code below to import the map:
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.Map3D;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.View;
import com.google.maps.geom.Attitude;
// Creating map variable
var map:Map3D;
/ Creating map
create_map();
function create_map()
{
map = new Map3D();
map.key = "your api key";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);
}
function onMapReady(event:MapEvent):void
{
map.setCenter(new LatLng(48.207401,16.372805), 13);
map.setAttitude(new Attitude(20,30,0));
map.viewMode = View.VIEWMODE_PERSPECTIVE;
}
In order to create the marker, you need to put some ActionScript again. Go to ActionScript panel and copy the following code. Change the classes to match yours if necessary.
var c:Marker = new Marker(new LatLng(-33.925272,18.423557),
new MarkerOptions({icon:new capeTown()}));
map.addOverlay(c);
var p:Marker = new Marker(new LatLng(50.075651,14.431229),
new MarkerOptions({icon:new prague()}));
map.addOverlay(p);
var v:Marker = new Marker(new LatLng(48.206371,16.375122),
new MarkerOptions({icon:new vienna()}));
map.addOverlay(v);}
If you want to have control fly.to animations with acrobat buttons. Since we call ActionScript from Javascript, we use the function ExternalInterface.addCallback that will build bridge between SWF and Acrobat Javascript. Create a new action layer and put there something similar to this. It should have the same marker coordinates:
function pr(e:MouseEvent = null):void
{
map.flyTo(new LatLng(50.075651,14.431229),12,new Attitude(0,0,4),5);
}
ExternalInterface.addCallback("pr",pr);
function vn(e:MouseEvent = null):void
{
map.flyTo(new LatLng(48.206371,16.375122),9,new Attitude(0,30,3),5);
}
ExternalInterface.addCallback("vn",vn)
function cp(e:MouseEvent = null):void
{
map.flyTo(new LatLng(-33.925272,18.423557),3,new Attitude(0,30,-10),3);
}
ExternalInterface.addCallback("cp",cp)
With map.flyTo function you can control the following parameters: LatLng, Zoom, Attitude, Time.
Now open your InDesign file again, that we have already prepared. Select the frame that will serve as placeholder for the map. With placeholder selected press CTRL + D (File – Import) to place your SWF map. Open the media panel and check Play on Page Load on. Choose None for Poster option. Now you are ready to export it to interactive PDF. Go to File – Export or CTRL + E and select Adobe PDF Interactive.
Open the file in Acrobat. You have your interactive Acrobat buttons and your embedded Google map there. The buttons do nothing now, except for the rollover effect if you have created any. In the Interactive tab tools choose select object tool and double click on one of the buttons. In the windows that arrive go to Actions and from Select action dropdown menu select Run a Javascript, Then Press Add. In a a new windows that open again put the following code:
getAnnotsRichMedia(this.pageNum)[0].callAS(“pr”);
Press OK and close
Reference
You may want to have a look at the Static Maps API https://developers.google.com/maps/documentation/staticmaps/. It allows you to request 640x640 Static Maps and you can adjust the zoom accordingly by altering the parameter. You can either use coordinates or names of places, which will get geocoded for your request.
Here are a few examples with different zoom levels and map types:
640x640, Zoom 14, Terrain Map:
http://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower&zoom=14&size=640x640
640x640, Zoom 18, Satellite: http://maps.googleapis.com/maps/api/staticmap?center=Eiffel+Tower&zoom=18&size=640x640&maptype=satellite
Be aware though that according to 10.1.2.(b) of the Terms of Use, you:
(b) No Direct Marketing. You must not print more than 5,000 copies of sales collateral
materials containing a screenshot of the Content for purposes of
commercial sales lead generation ("Direct Marketing") or incorporate
the Content as a core part of printed matter (such as printed maps or
guide books) that you redistribute for a fee. You must contact the
Google Maps API for Business sales team to obtain a direct license if
you desire to do either of the above.
Currently, I am working on automating maps. I wanted to select the region using mouse pointer.
find region -> drag mouse pointer -> Drop. Please suggest sikuli webdriver script for this.
There are a couple of built in Sikuli functions: dragDrop() will encompass both the drag and the drop (like the name suggests) Or, you can do the steps separately, if needed (drag(), mouseMove(), dropAt()). These are all in the documentation here.
I don't know much about webdriver or how it interacts with Sikuli, but hopefully its a starting place...
Here is my solution for enlarge a application window. I tested on both windows and linux OS and it work.
corner = find(Pattern('test.png' ).targetOffset(-36,-22))
drop_point = corner.getTarget().offset(dx, dy)
dragDrop(corner, drop_point)
The -36,-22 in function targetOffset(-36,-22)) can be adjust by sikuli IDE.
Here another example:
region1 = find("1429562753142.png")
dropRegion = Location(104,800)
dragDrop(region1, dropRegion)
keyUp()
I defined the reigion where the image is located.
Then I defined the drop region.
By using dragDrop() the image is moved.
And keyUp() is releasing the keys that where being hold down.
My project is based on Adobe AIR/Actionscript Project and it's a small desktop application. I opened a popup using PopupManager Class. So here is code.
var _dataviewPopup = new dataviewPopup();
/* PopUpManager.addPopUp(_dataviewPopup , FlexGlobals.topLevelApplication as DisplayObject, true);
PopUpManager.centerPopUp(_dataviewPopup);
and I remove popup using
PopupManager.removePopUp(_dataviewPopup);
So I want to give some animation to this popup when it appears and disappears, is it possible?
Is there any library available for it?
Have a look at this tutorial to see how you can use the NativeWindow class to animate new windows.
Hope it helps
http://blog.flashdesign-store.com/?p=128
I have an app that allows a user to use JQuery and Javascript to add images and position them in a div dynamically.
I would like to be able to submit the div with all the HTML to a WebService and receive back an image so we have a bitmap of the result of the end user's work.
I would prefer a solution in .Net as this is what I am most familiar with but am open to pretty much anything?
I would like to be able to submit the div with all the HTML to a WebService and receive back an image
Try http://browsershots.org!
Browsershots makes screenshots of your web design in different operating systems and browsers. It is a free open-source online web application providing developers a convenient way to test their website's browser compatibility in one place.
How about this. You load the html into a webbrowser control and then use the DrawToBitmap method. It doesn't show up on intellisense and this is probably not the best solution, but it works. Observe the DocumentCompleted event and add the following code:
private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
var bmp = new Bitmap(100, 100);
var rect = new Rectangle(webBrowser.Location.X, webBrowser.Location.Y, webBrowser.Width, webBrowser.Height);
webBrowser.DrawToBitmap(bmp, rect);
bmp.Save("test.jpg", ImageFormat.Jpeg);
}
You'll probably want to change the width and height of that bitmap object (do it in some smart way or something). Hope this helps.
EDIT: I see now that you are using a webservice for this, hence this solution probably won't work. I'll leave it here just for information's sake.
I was not able to figure out how to do this by submitting the html and receiving an image but I was able to create and ASHX handler that returns a png file based on this blog post
which was good enough for my scenario.
He uses CutyCapt to take a screen shot of an existing web page, write the image to a folder on the webserver and return it.