how to get a value from a edit control using coded UI test - coded-ui-tests

I am trying to get an Order number from a text field using coded UI TEST
The text field id is : order_no.
I know with selenium i would use:
String strOrderNumber=driver.findElement(By.id("order_no")).getAttribute("value");
My code in codedUi test
public static void getOrderNumber(UITestControl Control)
{
Control.TechnologyName = "web"; Control.SearchProperties.Add("Controltype", "Edit");
Control.SearchProperties.Add("Id", "order_no");
OrderNumber = Control.GetProperty("Text").ToString();
Console.Write(OrderNumber);
}
enter image description here

Related

Trying to write test case in Cucumber where I use one or more pieces of data

I'm trying to write out a test case where the input could be one or more items.
Example:
Scenario: Changes to a user's address in the system are saved to the database
Feature: Make a change to one or more of a user's address fields.
Given I'm logged into the system.
When I make a change to <field>.
And Click Save.
Then Changes are saved into database.
|Field|
|Street Address|
|City|
|State|
|ZIP Code|
This scenario works if its only one field I'm changing, ex. ZIP Code.
But how do I write it for scenarios where I want to change multiple items?
Example, change City and State or City, State, and ZIP code.
You need a Scenario Outline rather than a scenario alone. This is how you create a scenario outline:
Feature: Make a change to one or more of a user's address fields.
Scenario Outline: Changes to a user's address in the system are saved to the database
Given I'm logged into the system.
When I make a change to <Field>.
And Click Save.
Then Changes are saved into database.
Examples:
|Field|
|Street Address|
|City|
|State|
|ZIP Code|
A scenario outline is easily identified by the key phrase Scenario Outline. The purpose of a scenario outline is to loop through a test case with different input parameters. These input parameters are included in a data table underneath a section labeled "Examples". Lastly, the label of the table header must match a parameter used in one or more test steps, enclosed in angular brackets <>.
There are two ways you can do that
1. simple scenario outline. (fields are horizontal)
Scenario Outline: login registration
When I submit login details <Username> <Password> <UsernameDesc>
Examples:
|Username|Password|UsernameDesc|
|"uname1" |"password"|"testuserName1"|
|"uname2" |"password"|"testuserName2"|
step def for above method is
#When("I submit login details {string} {string} {string}")
public void register(String usrname, String pwd, String desc){
// use usrname, pwd, desc as desired
}
2. using data table (#DatatableType). (fields are vertical)
Scenario: login registration using cucumber data table
When I submit login details
|Username |"username"|"username1"|"username2"|
|Password |"password"|"password1"|"password2"|
|UsernameDesc |"testDesc"|"testDesc1"| "password2"|
step defs for above method
#DataTableType
public loginDetails logindetails(Map<String, String> entry) {
return new loginDetails(entry.get("Username"),entry.get("Password"),entry.get("UsernameDesc"));
}
#When ("^I submit login details$")
public void submitLoginDetails(DataTable dataTable ){
List<loginDetails> list = dataTable.transpose().asList(loginDetails.class);
list.stream().forEach(System.out::println);
for (loginDetails l : list) {
System.out.println("username::"+l.getUserName());
System.out.println("pwd::"+l.getPassword());
System.out.println("usernamedesc::"+l.getUsernameDesc());
}
}
pojo class used in above method is like this
public class loginDetails {
private String Username;
private String Password;
private String UsernameDesc;
public loginDetails(String uname, String pwd, String udesc){
this.Username=uname;
this.Password = pwd;
this.UsernameDesc = udesc;
}
public String getUserName() {
return Username;
}
public String getPassword() {
return Password;
}
public String getUsernameDesc() {
return UsernameDesc;
}
}

Can't change activity in my App using PlainText as login

I am a noob developer in android who is just learning to experiment with activities and stuff like that. Today I learnt about TextFields, and tried to use a normal plaintext EditText view as a username, a password-input type EditText view, and a button to which an onClick method by the name of "loginMethod" was attached. I used simple if-else statements by taking the inputs in the text fields to string and want to open a new activity when the desired username and password are entered, and to show a toast if not. However, on running the application it only gives the toast message for the error and doesn't start the activity.
The code for the method is attached below:
public void loginMethod(View view)
{
EditText username=(EditText) findViewById(R.id.username);
EditText password=(EditText) findViewById(R.id.password);
String user_name=username.getText().toString();
String pass_word=password.getText().toString();
Log.i("Info","Entered username: "+user_name+" and Entered password: "+pass_word);
Context context=getApplicationContext();
int duration= Toast.LENGTH_LONG;
if (user_name=="myuser" && pass_word == "mypass")
{
Intent i=new Intent(MainActivity.this,welcome.class);
startActivity(i);
}
else Toast.makeText(getApplicationContext(),"Wrong Username or Password!",duration).show();
}
The output when the image is run is also attached in the image below. Please help.
Check out the output screenshot from here
Change this line:
if (user_name.text.toString()=="myuser" && pass_word.text.toString() == "mypass")

How can I upload lot/serial # allocations in Purchase Receipt popup?

I would like to upload a spreadsheet of lot/serial #'s into the Allocation popup on the Purchase Receipts screen. It's not uncommon for my company to receive 1,000+ serial #'s in an order and entering them one-at-a-time via this popup is too cumbersome. (My serial numbers aren't sequential, so I can't use the Generate tool.)
I've found a related post here, but I'm unable make the source work.
How to include a dialog for file upload
... begin snippet ...
byte[] filedata = info.BinData;
using (NVExcelReader reader = new NVExcelReader())
{
Dictionary<UInt32, string[]> data = reader.loadWorksheet(filedata);
foreach (string[] textArray in data.Values)
{
// do stuff
}
}
...
The code references a class called NVExcelReader(). Where does this class originate from? Is this part of stock Acumatica? I've been unable to find this class in the source. I'm using Acumatica 2017 R2. Is it possible this class was renamed or moved in newer versions?
Can someone point me in the right direction or explain how I might go about recreating the functionality of NVExcelReader() in Acumatica?
NVExcelReader is not an Acumatica class, the main idea here is to use any existing class to read the excel file.
So what you really need to do:
declare PXUploadDialog element in your aspx file
<px:PXUploadDialog ID="ImportPanel" runat="server" Key="NewRevisionPanel" Height="120px" Style="position: static" Width="560px"
Caption="Import XML File (*.xml)" AutoSaveFile="false" RenderCheckIn="false" SessionKey="ImportStatementProtoFile" />
add a button delegate
public PXSelect<PO.POReceipt> NewRevisionPanel;
public PXAction<PO.POReceipt> ImportAllocations;
[PXUIField(DisplayName = "Import Allocations",
MapEnableRights = PXCacheRights.Update,
MapViewRights = PXCacheRights.Update,
Enabled = true)]
[PXButton()]
public virtual void importAllocations()
{
}
Get selected file data using PXInfo class
const string PanelSessionKey = "ImportStatementProtoFile";
PX.SM.FileInfo info = PX.Common.PXContext
.SessionTyped<PXSessionStatePXData>()
.FileInfo[PanelSessionKey] as PX.SM.FileInfo;
System.Web.HttpContext.Current.Session.Remove(PanelSessionKey);
if (info != null)
{
// here is your file data in bytes
byte[] filedata = info.BinData;
read your excel file in bytes using any existing library. Note this step is not related to Acumatica. You can find helpful information here and here for example
then set values from the file to Acumatica entity (POReceiptLineSplit for example)
Base.splits.Insert(new PO.POReceiptLineSplit()
{
InventoryID = Base.transactions.Current.InventoryID,
LocationID = Base.transactions.Current.LocationID,
LotSerialNbr = valueFromExcelFile1,
Qty = valueFromExcelFile2
});
NVExcelReader is not part of Acumatica framework. I say this because neither resharper was able to find NVExcelReader in Acumatica dlls nor search of string in Acumatica directory was able to find any file that contained NVExcelReader string value. Also Google search for NVExcelReader class doesn't give any good results beside referencing your thread on stackoverflow. In order to recreate NVExcelReader in Acumatica you can consider usage of some third party library which can read from excel files. There are plenty of options starting from COM interfaces, OLE DB for excel and Aspose library for parsing xml files.

Set different value for Sharepoint custom property of same web part in multiple different pages

I have visual web part and i am attempting to set custom property unique value on each pages. For example i have two aspx pages. Deal.aspx and Fund.aspx. Both page is having same web part used. When i set the value custom property in web part of Deal.aspx the same value gets reflect in Fund.aspx page web part as well. I read about PersonalizationScope but it did not help for my scenario. Below is the custom property i have created.
public static string ListName;
[Category("Extended Settings"),
Personalizable(PersonalizationScope.User),
WebBrowsable(true),
WebDisplayName("Enter List Name"),
WebDescription("Please Enter a List Name")]
public string _ListName
{
get { return ListName; }
set
{
// Sample Validation
Regex oRegEx = new Regex("[a-zA-Z]+");
if (!oRegEx.IsMatch(value))
throw new Microsoft.SharePoint.WebPartPages.
WebPartPageUserException(
"Please enter alphabeth characters only");
ListName = value;
}
}
Problem is not in SharePoint or PersonalizationScope. It works fine. Problem is in static property ListName. Static properties are "shared" between all instances of the same class. So all your webparts will have the same value there.

J2me ticker not displayed correctly. Help me to try to solve it

I'm developing a mobile application with j2me. The configuration is "CLDC 1.1" & "MIDP 2.0". The phone I used for testing purpose is "NOKIA C2-01". The phone is "S40" device.
In that mobile app the data is send to server and perform based on response. I added the ticker to the Displayable (the Displayable may be form, list, etc).
When application runs the ticker is shown sometimes correctly, but sometimes the ticker is not correctly displayed: the space for ticker is appeared above the form/list, but ticker is not displayed.
Please help me to solve it.
I am just assigning the form and list to the object of (Displayable) displayable.
Then I create a new Ticker object and I set the ticker by displayable.setTicker(Ticker ticker) method. Sometimes ticker is shown correctly sometimes ticker not shown.
the following are my conding snippets-some sample only
public class Controller
{
Form loginForm;
List userLit;
Ticker tikcer;
Display display;
Displayable displayable;
public Controller()
{
display=Display.getDisplay(midlet);
displayable=null;
loginForm=new LoginForm("Login");
userList=List("user list", Choice.IMPLICIT);
}
public void showLoginForm()
{
displayable=loginForm;
display.setCurrent(loginForm);
}
public void showUserList()
{
displayable=userList;
display.setCurrent(userList);
}
public void setTickerToDisplayable(String str)
{
ticker=null;
if((str==null)||(str.length()<1))
ticker=null;
else
ticker=new Ticker(str);
displayable.setTicker(ticker);
}
}
I find the solution.Sometimes if application gets more memory means then ticker not displayed correctly.
Now i modified my code with respect to decrease the memory leaks.Now its working

Resources