如何在编码的UI项目中使用.resw资源文件 [英] How to use .resw resource file in coded UI project

查看:77
本文介绍了如何在编码的UI项目中使用.resw资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为UWP应用程序开发编码UI自动化。想要使用.resw文件来验证翻译文本。但是我们无法添加.resw文件。想知道如何添加.resw文件并在UWP的编码UI项目中使用它。

解决方案

您好Vijay Senniappan,


欢迎来到MSDN论坛。


经过多次实验,.resw文件无法在代码UI测试中用作嵌入式源代码,但可以支持.resx文件。


##它们之间的区别


它们都被用作项目的资源。 .resw文件适用于Windows应用商店应用(通用窗口),而.resx文件(.Net框架)适用于桌面应用。代码ui测试项目适用于.Net框架。


尽管文件扩展名不同,但.resw文件格式与.resx文件格式相同,但.resw文件除外可能只包含字符串和文件路径。您可以使用Visual Studio资源编辑器来创建和编辑资源。在编译
时,应用程序的所有.resw文件都由MakePRI实用程序打包到单个PRI文件中,并包含在应用程序的部署包中。推荐更多

here


## 


如果要在编码的ui测试中使用现有的.resw文件,可以手动将文件的扩展名从.resw更改为.resx。



##如何在编码的UI测试项目中使用.resx文件?


请按照以下步骤操作:


> 1右键单击解决方案资源管理器中的属性,然后添加新项目,选择资源文件(或添加现有文件,浏览器特定文件夹,设置显示所有文件,然后选择.resx文件)



> 2键入以下示例代码使用System.Resources调用文件中的数据 

; 
使用CodedUITestProject1.Properties;

ResourceManager testresource = new ResourceManager(typeof(Resource1));

string str = testresource.GetString(" String1"); // Stirng1是value Name

Assert.AreEqual(str," Button");

预计会有任何反馈。


最好的问候,


Dylan


We are developing coded UI automation for UWP application. Want to use .resw file for verifying the translation texts. However we could not add .resw file. Would like to know how to add .resw file and use it in coded UI project for UWP.

解决方案

Hi Vijay Senniappan,

Welcome to MSDN forum.

After many experiments, the .resw file could not be used as embedded source in the code UI test, but the .resx file could be supported.

## the difference between them

Both of they is used as resource for your project. The .resw file is for Windows store app(universal windows) and the .resx file(.Net framework) works for desktop app. The code ui test project is work on the .Net framework.

Despite the difference of file extension, the .resw file format is identical to the .resx file format, except that .resw files may contain only strings and file paths. You can use the Visual Studio resource editors to create and edit resources. At compile time, all the .resw files for an app are packed into a single PRI file by the MakePRI utility and included with the app's deployment package. Refer more here.

## 

If you want to use the existed .resw file in the coded ui test, you could change the extension of the file from .resw to .resx manually.

##How to use the .resx file in coded UI test project?

Please follow the steps below:

>1 Right-click the properties in the solution explorer , then add new item, select the Resource File (Or add a existing file, browser the  specific folder, set display all files, then select .resx file)

>2 Type the following sample code to call the data from the file 

using System.Resources;
using CodedUITestProject1.Properties;

ResourceManager testresource = new ResourceManager(typeof(Resource1));

string str = testresource.GetString("String1");//Stirng1 is value Name

Assert.AreEqual(str, "Button");

Any feedback will be expected.

Best Regards,

Dylan


这篇关于如何在编码的UI项目中使用.resw资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆