Selenium to record browser actions as video - firefox

I wrote a selenium code to run automation in webpage via Firefox
I need to record the browser actions like a visual
Is there any way to record the screen on firefox as a video using addons or any other. I am using firefox version 34

You can include it in your test. Here is an example for C#. To make this work, you need to install Microsoft Expression Encoder and add the reference to your project
using Microsoft.Expression.Encoder.ScreenCapture;
string timestamp = DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss");
ScreenCaptureJob vidrec = new ScreenCaptureJob();
vidrec.OutputScreenCaptureFileName = #"C:/yourPathToSaveFile/yourFilename " + timestamp + ".wmv";
vidrec.Start();
// your test
vidrec.Stop();

http://learnseleniumtesting.com/recording-selenium-test-execution/
using System;
.
.
using OpenQA.Selenium;
.
.
using Microsoft.Expression.Encoder.ScreenCapture;
using System.Drawing;
using Microsoft.Expression.Encoder.Profiles;
using Microsoft.Expression.Encoder;
namespace FRAMEWORK
{
//Call this method in setup method.
public static void StartRecordingVideo()
{
//Provide setting in config file if you want to do recording or not.
if (testEInfo.isRecording)
{
job = new ScreenCaptureJob();
job.CaptureRectangle = Screen.PrimaryScreen.Bounds;
job.ShowFlashingBoundary = true;
//provide the location where you want to save the recording.
job.OutputPath = AutomationLogging.newLocationInResultFolder;
job.Start();
}
}
}

Related

Winapp driver : How to select items from the list using Java

I am trying to automate Windows app using Win app driver, How can we select item from the list using java?
WindowsElement comboBoxElement1= (WindowsElement) DesktopSession.findElementsByXPath("//List[#Name='Select Outlet:']//*[starts-with(#AutomationId,'listBox')]");
comboBoxElement1.findElementByName("!xyz").click();
I am getting error as not being able to locate the element. Also most of the cases findElementByXpath is not working.
UI looks as below:
use sendkeys:
comboBoxElement1.SendKeys("name of the item");
UPDATE
comboBox.Click();
string xPathListItem = $"//Text[contains(#Name, '{dateTom}')]/preceding::Custom[1]/ComboBox/ListItem[1]"; //xPath of your item in combobox
elem = (WindowsElement)window.FindElementByXPath(xPathListItem);
app.DoubleClick(elem);
here is my DoubleClick method:
public void DoubleClick(WindowsElement elem)
{
session.Mouse.MouseMove(elem.Coordinates);
session.Mouse.DoubleClick(null);
}

Define download path dotnetbrowser

I use dotnetbrowser to display a web browser on a old windows framework.
have you an idea to define the download path ?
My dotnetbroser is enable, i can show my webpage but i don't found in documentation or exemple how define this simple download path.
The only exemple that i've found is about the download event detection.
I use WPF in C#
Thanks.
The DotNetBrowser.DownloadItem.DestinationFile property is writable and can be used to configure the path to store the file.
To set this property in your application, you need to subclass the DotNetBrowser.DefaultDownloadHandler and implement its AllowDownload(DownloadItem) method. Then you need to configure your download handler as shown in the documentation article: File Download
You can also configure and use DotNetBrowser.WPF.WPFDefaultDownloadHandler instance to show file chooser and select the path to store the file.
This is a solution
Défine your browser like variable :
BrowserView myBrowserView;
Browser myBrowser;
Create the browser properly :
this.myBrowser = BrowserFactory.Create();
this.myBrowserView = new WPFBrowserView(this.myBrowser);
Create event detection for download
this.myDowloadHandler = new SampleDownloadHandler();
this.myBrowser.DownloadHandler = myDowloadHandler;
Add it to a container, here, a grid
grid_navigateur.Children.Add((UIElement)myBrowserView.GetComponent());
Now we are going to use our "SampleDownloadHandler" class
class SampleDownloadHandler : DownloadHandler
{
public bool AllowDownload(DownloadItem download)
{
download.DestinationFile = "exemple\of\path\whith\file\name";
download.DownloadEvent += delegate(object sender, DownloadEventArgs e)
{
DownloadItem downloadItem = e.Item;
if (downloadItem.Completed)
{
System.Windows.MessageBox.Show("Download complete");
}
};
return true;
}
My personalisated class define path and name of the file who is download and pop a message when is over.
(to found the file name, you do to cut the string download.DestinationFile after the last )

Getting error about a required member

I am developing a Windows 8.1 application in Visual Studio 2013 to create an Excel Sheet at run time. Visual Studio doesn't show any error, but when I run the app, there is a run time error that is :
Error 1 Missing compiler required member
'System.Runtime.InteropServices.LCIDConversionAttribute..ctor' D:\GS\Projects\excel\excel\CSC excel
Here is my CS code :
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
namespace excel
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook workbook = null;
Microsoft.Office.Interop.Excel.Workbooks workbooks = null;
Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
workbooks = excelApp.Workbooks;
workbook = workbooks.Add(1);
worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
excelApp.Visible = true;
worksheet.Cells[1, 1] = "Value1";
worksheet.Cells[1, 2] = "Value2";
worksheet.Cells[1, 3] = "Addition";
}
}
}
In the above code, there is no red line shown in VS-2013 for error.
I added references for Excel : Microsoft.Office.Interop.Excel
Does anyone have a solution ?
Sorry you can not automate office from a store app. I would look at using something like syncfusion's docio if you want to create a spread sheet

Unity3D cloud builds iOS and xcode 7

I'm working on Unity 5.1.1f1 and using Unity cloud build for iOS with xcode 7 option. My problem is I can't disable App transport Security for my server url, disable bitcode and enable "requires full screen" option on xcode 7. So, game always errors when build.
Any solution is appreciated
Thanks for advice!
This is how I did it. It disables BitCode and enable UIRequiresFullScreen.
Tested with XCode 7.3 and Unity 5.4.1p2 version.
Please upgrade to latest version of Unity
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif
public class Postprocessor : AssetPostprocessor
{
#if UNITY_IOS
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));
string target = proj.TargetGuidByName("Unity-iPhone");
proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");
File.WriteAllText(projPath, proj.WriteToString());
// Add url schema to plist file
string plistPath = path + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
PlistElementDict rootDict = plist.root;
rootDict.SetBoolean("UIRequiresFullScreen",true);
plist.WriteToFile(plistPath);
}
}
#endif
}

Powerpoint interop

I'm new to .NET. I want to make a console application that converts a .pptx file into a .wmv.I've managed to do this using powerpoint interop.But i have some problems.First If i build the application and tranfer it to another computer i get an exception Error HRESULT E_FAIL has been returned for COM object(i have powerpoint in both PCs).If i run it on the one that i wrote it i everything works alright.But not for the first time.Meaning that when i start my pc and run it i'll get the same exception and the second time i'll try to run it will run properly.What could be the problem?iguess something with interop and powerpoint but i can't figure it out.
Ok here is the code:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using System.Runtime.InteropServices;
using System.IO;
using System;
namespace Microsoft.Office.Interop.PowerPoint
{
class Program
{
static void Main(string[] args)
{
string fileName = args[0];
string exportName = args[1];
string exportPath = args[2];
Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
ppApp.Visible = MsoTriState.msoTrue;
ppApp.WindowState = PpWindowState.ppWindowMinimized;
Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = ppApp.Presentations;
Microsoft.Office.Interop.PowerPoint._Presentation oPres = oPresSet.Open(fileName,
MsoTriState.msoFalse, MsoTriState.msoFalse,
MsoTriState.msoFalse);
try
{
oPres.CreateVideo(exportName);
oPres.SaveCopyAs(String.Format(exportPath, exportName),
PowerPoint.PpSaveAsFileType.ppSaveAsWMV,
MsoTriState.msoCTrue);
}
finally
{
ppApp.Quit();
}
}
}
}
_Presentation.CreateVideo doesn't create a video out of a powerpoint. It creates a video inside of a powerpoint. That's what the documentation says, anyway.
Try _Presentation.SaveAs and then use PpSaveAsFileType.ppSaveAsWMV for the file type.

Resources