or
Public
Sub
sa_SetupLookups_SetLookupTextItems()
Dim
row
As
Integer
Dim
col
As
Integer
Dim
minCol
As
Integer
= 3
'First column for lookupText values, column C
Dim
maxCol
As
Integer
= 11
'Last column for lookupText values, column K
Dim
input
As
String
=
"C:\Users\edwardni\Documents\Test Studio Projects\Accelerate\Data\AccelerateData.xlsx"
Dim
app
As
New
Microsoft.Office.Interop.Excel.Application()
'Dim inputBook As Microsoft.Office.Interop.Excel.Workbook = app.Workbooks.Open(input, 0, False, 5, "", "", False, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", True, False, 0, True, False, False) 'This is write
'Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)
Dim
inputBook
As
Microsoft.Office.Interop.Excel.Workbook = app.Workbooks.Open(input, 0,
True
, 5,
""
,
""
,
False
, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
""
,
True
,
False
, 0,
True
,
False
,
False
)
'This is read-only
Dim
inputSheet
As
Microsoft.Office.Interop.Excel.Worksheet =
DirectCast
((inputBook.Worksheets.Item(
"Lookups"
)), Microsoft.Office.Interop.Excel.Worksheet)
Dim
theLookupCode
As
Object
= GetExtractedValue(
"CodeText"
)
Dim
lookupCode
As
String
= theLookupCode.ToString().Trim()
Dim
lookupText
As
String
Dim
NoMatchingTableCell
As
HtmlTableCell = Pages.LookupEdit.NoMatchingTableCell
Select
Case
lookupCode
Case
"City"
row = 2
Case
"CompanyType"
row = 3
Case
"ContactType"
row = 4
Case
"DataSourceType"
row = 5
Case
"DataType"
row = 6
Case
"IndustryType"
row = 7
Case
"SalutationType"
row = 8
Case
"Screen"
row = 9
Case
"Size"
row = 10
Case
"CategoryType"
row = 11
Case
"PriorityType"
row = 12
Case
"ProjectClientsType"
row = 13
Case
"SeverityType"
row = 14
Case
"StatusType"
row = 15
Case
Else
row = 999
End
Select
If
(row <> 999)
Then
For
col = minCol to maxCol
lookupText = TryCast(
DirectCast
(inputSheet.Cells(row, col), Microsoft.Office.Interop.Excel.Range).Text,
String
)
Log.WriteLine(
"DEBUG LINE theLookupCode: "
+ theLookupCode.ToString())
Log.WriteLine(
"DEBUG LINE lookupCode: "
+ lookupCode.ToString())
Log.WriteLine(
"DEBUG LINE row: "
+ row.ToString())
Log.WriteLine(
"DEBUG LINE col: "
+ col.ToString())
Log.WriteLine(
"DEBUG LINE lookupText: "
+ lookupText.ToString())
If
(lookupText =
"."
)
Then
Exit
For
Else
'Search table to see if lookupText already exists
Pages.LookupEdit.Text.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop)
ActiveBrowser.Window.SetFocus
Pages.LookupEdit.Text.MouseClick
Manager.Desktop.KeyBoard.TypeText(
""
, 50, 100)
'Clear search field of any pre-existing text
System.Threading.Thread.Sleep(1000)
'Give table time to repopulate
Pages.LookupEdit.Text.MouseClick
Manager.Desktop.KeyBoard.TypeText(lookupText, 50, 100)
'Enter value held in lookupText (e.g. London) in 'Text'
System.Threading.Thread.Sleep(1000)
'Give table time to complete the search
NoMatchingTableCell.Wait.ForExists(10000)
If
(Assert.IsTrue(NoMatchingTableCell.IsVisible) =
True
)
Then
'lookupText already exists, so empty the search field ready for the next
Pages.LookupEdit.Text.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop)
ActiveBrowser.Window.SetFocus
Pages.LookupEdit.Text.MouseClick
Manager.Desktop.KeyBoard.TypeText(
""
, 50, 100)
System.Threading.Thread.Sleep(1000)
Else
Pages.LookupEdit.AddSpan.Click(false)
Pages.AddNewLookupItem.HtmlTag.BaseElement.Wait.ForCondition(
Function
(a_0, a_1) ArtOfTest.Common.CompareUtils.StringCompare(a_0.InnerText,
"Add New Lookup Item"
, ArtOfTest.Common.StringCompareType.StartsWith), false,
Nothing
, 10000)
Pages.AddNewLookupItem.CultureBasedTextTextText.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop)
ActiveBrowser.Window.SetFocus
Pages.AddNewLookupItem.CultureBasedTextTextText.MouseClick
Manager.Desktop.KeyBoard.TypeText(lookupText, 50, 100)
'Add the new lookupText
Pages.AddNewLookupItem.ItemIsActiveCheckBox.Check(true, true)
'Check 'ItemIsActiveCheckBox' to be 'True'
Pages.AddNewLookupItem.Submit.Click(false)
'Click 'Submit' (Save button)
End
If
End
If
Next
col
End
If
'All required text entries for the supplied lookupCode have been made, so exit back to the main Lookups screen
Pages.LookupEdit.BackToListSpan.Click(false)
'Free up resources:
row =
Nothing
col =
Nothing
minCol =
Nothing
maxCol =
Nothing
input =
Nothing
app =
Nothing
inputBook =
Nothing
inputSheet =
Nothing
lookupText =
Nothing
theLookupCode =
Nothing
lookupCode =
Nothing
NoMatchingTableCell =
Nothing
'Close Excel, preventing any Save prompt, & free up the process
inputBook.Saved =
True
app.Quit()
app =
Nothing
End
Sub
[CodedStep(@"RightClick on Item250Border", RequiresSilverlight = true)]
public void CreateAppointment_CodedStep()
{
//declare variables and set to null
int beforeAppCount = Convert.ToInt16(GetExtractedValue("BeforeAppointmentCount")); //before count
int appTimeIndex = beforeAppCount % 5;
// Appointment start times will cycle between 10:00 AM, 1:00 pm, 2:00pm, 3:15 PM and 4:00 PM
switch (appTimeIndex)
{
case 0:
// RightClick on Item154Border - 10:00 am
Log.WriteLine("Creating appointment at 10:00 AM");
Pages.QAAUTOSYNC1228183918.SilverlightApp.Item154Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 100, 45, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
break;
case 1:
// RightClick on Item202Border - 1:00pm
Log.WriteLine("Creating appointment at 1 PM");
Pages.QAAUTOSYNC1228183918.SilverlightApp.Item202Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 99, 55, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
break;
case 2:
// RightClick on Item218Border - 2:00pm
Log.WriteLine("Creating appointment at 2 PM");
Pages.QAAUTOSYNC1228183918.SilverlightApp.Item218Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 99, 30, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
break;
case 3:
// RightClick on Item238Border - 3:15pm
Log.WriteLine("Creating appointment at 3:15 PM");
Pages.QAAUTOSYNC1228183918.SilverlightApp.Item238Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 99, 40, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
break;
case 4:
// RightClick on Item250Border - 4:00pm
Log.WriteLine("Creating appointment at 4 PM");
Pages.QAAUTOSYNC1228183918.SilverlightApp.Item250Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 100, 40, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
break;
default: // this code should never be executed as long as the number of appointment time options is 3
// RightClick on Item154Border - 10:00 am
Log.WriteLine("Creating appointment at 10 AM (default)");
Pages.QAAUTOSYNC1228183918.SilverlightApp.Item154Border.User.Click(ArtOfTest.WebAii.Core.MouseClickType.RightClick, 100, 45, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
break;
}
}