Emu4kQ6T
2017-01-12 03:38:07

using NUnit.Framework;

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Xamarin.UITest;

namespace fieldapp.UITests
{
[TestFixture(Platform.Android)]
[TestFixture(Platform.iOS)]

public class Tests
{
IApp app;
private readonly Platform _platform;
private const string testUser = "intern280";
private const string testPass = "pO$LoW94";

public Tests(Platform platform)
{
this._platform = platform;
}

private object Invoke(string method, object val = null)
{
if (_platform == Platform.iOS)
{
return app.Invoke($"{method}:", val ?? "").ToString();
}
return app.Invoke(method, val);
}

[SetUp]
public void BeforeEachTest()
{
app = AppInitializer.StartApp(_platform);
Invoke("SetTestFlag");
}

[Test]
public void TestLogin()
{
takeScreenshot("Given that I'm on the login screen, and I click the choose server button");
ClickButtonWithServers();
takeScreenshot("Then I should see a list of the available servers");
SelectServerTP();
takeScreenshot("When I click on the server from the list, then I should be back on the login screen, and selected server should be visible under 'Server' label");
TestWriteLoginAndPassword(testUser, testPass);
takeScreenshot("When I fill in the correct login and password, and I tap the login button");
ClickLoginButton();
app.WaitForElement("projectslistViewTest", "Projects list did not appear!", timeout: TimeSpan.FromSeconds(300));
takeScreenshot("Then I should be succesfully logged in and see the list of the projects");
}

[Test]
public void TestProgressIndicator()
{
ClickButtonWithServers();
SelectServerTP();
TestWriteLoginAndPassword(testUser, testPass);
takeScreenshot("Given that I input the correct credentials on the login screen, when I tap the login button");
ClickLoginButton();
app.WaitForElement("progressPageTest", "Progress indicator did not appear!", timeout: TimeSpan.FromSeconds(30));
takeScreenshot("Then I should see the progress indicator");
app.WaitForElement("projectslistViewTest", "Projects list did not appear!", timeout: TimeSpan.FromSeconds(350));
takeScreenshot("And then I should see the list of the projects");
}

[Test]
public void TestLoginWrongCredentials()
{
ClickButtonWithServers();
SelectServerTP();
TestWriteLoginAndPassword("A", "B");
takeScreenshot("Given that I input the wrong credentials on the login screen, and I tap the login button");
ClickLoginButton();
AssertLabelHasText("messageLabelTest", "Login failed", "Error message not displayed");
takeScreenshot("Then I should see an error message that login has failed");
}

[Test]
public void TestLoginIncorectValues()
{
WriteStringToUsername(" ");
takeScreenshot("Given that I input incorrect values (in this case empty login and password) on the login screen, and I tap the login button");
ClickLoginButton();
AssertLabelHasText("messageLabelTest", "Invalid login or password", "Error message not displayed");
takeScreenshot("Then I should see an error message about invalid login or password");
}

[Test]
public void TestLoginAndChooseProject()
{
ClickButtonWithServers();
SelectServerTP();
TestWriteLoginAndPassword(testUser, testPass);
ClickLoginButton();
takeScreenshot("Given that I have successfully logged in");
app.WaitForElement("projectslistViewTest", "Projects list did not appear!", timeout: TimeSpan.FromSeconds(300));
takeScreenshot("Then I should see the list of the projects. When I tap the project name");
app.Tap("Template für FotoPusher");
app.WaitForElement("documentsTypelistViewTest", "Document types list did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should see the list of types of documents in the project");
}

[Test]
public void TestLoginAndChooseDocumentType()
{
LoginAndChooseProject();
takeScreenshot("Given that I have chosen the project, and I tap the document type");
app.Tap("Photo Documentation");
app.WaitForElement("documentsListViewTest", "Document List did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should see the list of documents in the given category");
}

[Test]
public void TestAddNewDocument()
{
LoginAndChooseDocumentType();
takeScreenshot("Given that I'm on the Document List screen, and I tap the ADD button");
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");

//Filling the data

app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should be on the New Document screen");
app.EnterText("Subject_Entry", "doc1");

app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Attachments_Entry");
//AddPhotoAttachment();

app.WaitForElement("Description_Entry", "Description Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.EnterText("Description_Entry", "exampleDescription");
app.DismissKeyboard();

app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry"), "Selection Place Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("SelectionPlace_Entry");
app.Tap("SelectionPlace_Entry");
app.WaitForElement("searchingListTest", "List of buildings did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Building A");

app.WaitForElement(c => c.All().Marked("AuswahlType_Entry"), "Auswahl Type Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("AuswahlType_Entry");
app.Tap("AuswahlType_Entry");
app.WaitForElement("searchingListTest", "List of Auswahl Types did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Defect");

app.WaitForElement(c => c.All().Marked("Latitude_Entry"), "Latitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Latitude_Entry");
app.EnterText("Latitude_Entry", "23.23252");
app.DismissKeyboard();
app.WaitForElement(c => c.All().Marked("Longitude_Entry"), "Longitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Longitude_Entry");
app.EnterText("Longitude_Entry", "32.2652");
app.DismissKeyboard();
setDateInDatePicker(2016, 3, 12);
takeScreenshot("When I enter the data, and I tap the save button");
app.WaitForElement("save", "Save button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("save");
app.WaitForElement("doc1", "Added document doc1 did not appear on the list!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should be back on the Document List screen, and the newly added document should be on the list");
app.Back();
takeScreenshot("When I go back on the Document Types screen, and I select the document type");
app.Tap("Photo Documentation");
app.WaitForElement("documentsListViewTest", "Document list did not appear!", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement("doc1", "Added document doc1 did not appear on the list!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then the newly added document should still be there. When I tap on the document name");

//Checking if the document was saved correctly

app.Tap("doc1");

app.WaitForElement(c => c.Marked("Subject_Entry").Text("doc1"), "Subject text field contains incorrect data!", timeout: TimeSpan.FromSeconds(10));

app.WaitForElement("Attachments_Entry", "Attachment image did not appear!", timeout: TimeSpan.FromSeconds(10));

app.WaitForElement(c => c.Marked("Description_Entry").Descendant().Text("exampleDescription"), "Description text field contains incorrect data! Expected value: 'exampleDescription'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry").Descendant().Text("Building A"), "Selection Place text field contains incorrect data! Expected value: 'Building B'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("AuswahlType_Entry").Descendant().Text("Defect"), "Auswahl Type text field contains incorrect data! Expected value: 'Defect'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("Latitude_Entry").Text("23.23252"), "Latitude text field contains incorrect data! Expected value: '23.23252'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("Longitude_Entry").Text("32.2652"), "Longitude text field contains incorrect data! Expected value: '32.2652'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("RecordingDate/Time_Entry").Text("3/12/2016"), "Recording Date/Time text field contains incorrect data! Expected value: '3/12/2016'", timeout: TimeSpan.FromSeconds(10));

takeScreenshot("Then I should see that entire document was saved properly");

}

[Test]
public void TestGPSCoordinatesFetch()
{
app.Device.SetLocation(53.4285, 14.5528);
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Given I am on the New Document screen and the device has GPS signal");

if (this._platform == Platform.Android)
{
app.WaitForElement("More options", "More Options button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("More options");
app.WaitForElement("GPS", "GPS button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("When I open the options menu, and I click the GPS button");
}
else if (this._platform == Platform.iOS)
{
app.WaitForElement("GPS", "GPS button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("When I tap the GPS button");
}

app.Tap("GPS");

app.WaitForElement(c => c.All().Marked("Latitude_Entry").Text("53.4285"), "Latitude is incorrect! Expected value: 53.4285", timeout: TimeSpan.FromSeconds(15));
app.WaitForElement(c => c.All().Marked("Longitude_Entry").Text("14.5528"), "Longitude is incorrect! Expected value: 14.5528", timeout: TimeSpan.FromSeconds(15));
takeScreenshot("Then the correct GPS coordinates should be fetched and entered into Latutude and Longitude fields");
}

[Test]
public void TestGPSCoordinatesFetchWhenNoSignal()
{
Invoke("SetGps", "Noise");
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Given I am on the New Document screen and the device's GPS is on but has no signal");

if (this._platform == Platform.Android)
{
app.WaitForElement("More options", "More Options button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("More options");
app.WaitForElement("GPS", "GPS button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("When I open the options menu, and I click the GPS button");
}
else if (this._platform == Platform.iOS)
{
app.WaitForElement("GPS", "GPS button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("When I tap the GPS button");
}

app.Tap("GPS");

app.WaitForElement(c => c.All().Marked("Latitude_Entry").Text("Can't read GPS"), "Latitude is incorrect! Expected value: 'Can't read GPS'", timeout: TimeSpan.FromSeconds(15));
app.WaitForElement(c => c.All().Marked("Longitude_Entry").Text("Can't read GPS"), "Longitude is incorrect! Expected value: 'Can't read GPS'", timeout: TimeSpan.FromSeconds(15));
takeScreenshot("Then there should be a 'Can't read GPS' message in both the Latitude and Longitude fields");
}

[Test]
public void TestGPSCoordinatesFetchWhenGPSIsOff()
{
Invoke("SetGps", "Off");
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Given I am on the New Document screen and the device's GPS is off or unavailable");

if (this._platform == Platform.Android)
{
app.WaitForElement("More options", "More Options button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("More options");
app.WaitForElement("GPS", "GPS button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("When I open the options menu, and I click the GPS button");
}
else if (this._platform == Platform.iOS)
{
app.WaitForElement("GPS", "GPS button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("When I tap the GPS button");
}

app.Tap("GPS");

app.WaitForElement(c => c.All().Marked("Latitude_Entry").Text("GPS unavailable"), "Latitude is incorrect! Expected value: 'GPS unavailable'", timeout: TimeSpan.FromSeconds(15));
app.WaitForElement(c => c.All().Marked("Longitude_Entry").Text("GPS unavailable"), "Longitude is incorrect! Expected value: 'GPS unavailable'", timeout: TimeSpan.FromSeconds(15));
takeScreenshot("Then there should be a 'GPS unavailable' message in both the Latitude and Longitude fields");
}

[Test]
public void TestProperFieldsVisibleForNewDocument()
{
checkFields("visible");
}

[Test]
public void TestAddPhotoAttachmentFromCamera()
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Given that I'm on the New Document screen, when I tap the 'Attachments' button");
//app.Tap("Attachments_Entry");
//takeScreenshot("Then the list of options should appear. When I tap the 'Take a photo' option");
//app.WaitForElement("Take a photo", "'Take a photo' button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Take a photo");
app.WaitForElement("Attachments_Entry", "Attachment image did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then the photo should be taken, and it should appear in the miniature.");
}

[Test]
public void TestAddPhotoAttachmentFromGallery()
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Given that I'm on the New Document screen, when I tap the 'Attachments' button");
//app.Tap("Attachments_Entry");
//takeScreenshot("Then the list of options should appear. When I tap the 'Select photo from gallery' option");
//app.WaitForElement("Select photo from gallery", "'Select photo from gallery' button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Select photo from gallery");
app.WaitForElement("Attachments_Entry", "Attachment image did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then the photo should be selected from gallery, and it should appear in the miniature.");
}

/*[Test]
public void TestViewAttachmentPreview()
{
LoginAndAddPhotoAttachment();
takeScreenshot("Given that I'm on Attachments screen, and there is an attachment added, when I tap the attachment");
app.WaitForElement("photostub_1", "photostub_1 attachment did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("photostub_1");
app.WaitForElement("photostub_1", "Attachment preview screen did not appear!", timeout: TimeSpan.FromSeconds(10));

if (this._platform == Platform.Android)
app.WaitForElement(c => c.Class("FormsImageView"), "Attachment preview did not appear!", timeout: TimeSpan.FromSeconds(10));
else if (this._platform == Platform.iOS)
app.WaitForElement(c => c.Class("UINavigationTransitionView").Class("UIImageView"), "Attachment preview did not appear!", timeout: TimeSpan.FromSeconds(10));

takeScreenshot("Then I should see preview of the attachment");
}*/

[Test]
public void TestEditDocument()
{
//Adding document for test
AddNewDocument();
takeScreenshot("Given that I'm on the Document List screen and there is a document already on the list, when I tap on the document");
app.WaitForElement("doc1", "doc1 document did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("doc1");
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should be on the document edit screen");

//Editing document

app.ClearText("Subject_Entry");
app.EnterText("Subject_Entry", "editedSubject");

if (this._platform == Platform.iOS)
{
app.Tap(c => c.All().Marked("Subject_Entry"));
app.DismissKeyboard();
app.ClearText("Subject_Entry");
app.EnterText("Subject_Entry", "editedSubject");
app.Tap(c => c.All().Marked("Subject_Entry"));
app.DismissKeyboard();
}

//editing attachment

app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Attachments_Entry");
//AddPhotoAttachment();

app.WaitForElement("Description_Entry", "Description Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));

if (this._platform == Platform.Android)
app.ClearText("Description_Entry");
else if (this._platform == Platform.iOS)
app.ClearText(c => c.All().Marked("Description_Entry").Class("UITextView"));

app.EnterText("Description_Entry", "editedDescription");
app.DismissKeyboard();

app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry"), "Selection Place Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("SelectionPlace_Entry");
app.Tap("SelectionPlace_Entry");
app.WaitForElement("searchingListTest", "List of buildings did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Building B");

app.WaitForElement(c => c.All().Marked("AuswahlType_Entry"), "Auswahl Type Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("AuswahlType_Entry");
app.Tap("AuswahlType_Entry");
app.WaitForElement("searchingListTest", "List of Auswahl Types did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Security");

app.WaitForElement(c => c.All().Marked("Latitude_Entry"), "Latitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Latitude_Entry");
app.ClearText("Latitude_Entry");
app.EnterText("Latitude_Entry", "100");
app.DismissKeyboard();
app.WaitForElement(c => c.All().Marked("Longitude_Entry"), "Longitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Longitude_Entry");
app.ClearText("Longitude_Entry");
app.EnterText("Longitude_Entry", "120");
app.DismissKeyboard();
setDateInDatePicker(2016, 6, 24);
takeScreenshot("When I edit the data and I tap the 'SAVE' button");

//Saving the edited document

app.WaitForElement("save", "Save button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("save");
app.WaitForElement("editedSubject", "Edited document 'editedSubject' did not appear on the list!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should be back on the Document List screen, and the edited document name should already be visible. When I tap on the document name");
app.Tap("editedSubject");
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));

//Checking if data got edited

app.WaitForElement(c => c.Marked("Subject_Entry").Text("editedSubject"), "Subject field was not edited! Expected value: 'editedSubject'", timeout: TimeSpan.FromSeconds(10));

app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));

app.WaitForElement(c => c.Marked("Description_Entry").Descendant().Text("editedDescription"), "Description field was not edited! Expected value: 'editedDescription'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry").Descendant().Text("Building B"), "Selection Place field was not edited! Expected value: 'Building B'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("AuswahlType_Entry").Descendant().Text("Security"), "Auswahl Type field was not edited! Expected value: 'Security'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("Latitude_Entry").Text("100"), "Latitude field was not edited! Expected value: '100'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("Longitude_Entry").Text("120"), "Longitude field was not edited! Expected value: '120'", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement(c => c.All().Marked("RecordingDate/Time_Entry").Text("6/24/2016"), "Recording Date/Time text field was not edited! Expected value: '6/24/2016'", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then I should see the edited document.");
}

[Test]
public void TestRemoveDocument()
{
//Adding document for test
AddNewDocument();

app.WaitForElement("doc1", "doc1 document did not appear!", timeout: TimeSpan.FromSeconds(10));

if (this._platform == Platform.Android)
{
takeScreenshot("Given that I'm on the Document List screen and there is a document already on the list, when I tap and hold the document name");
app.TouchAndHold("doc1");
app.WaitForElement("Delete", "'Delete' button didn't appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then 'Delete' button should appear on the upper bar. When I tap the delete button");
}
else if (this._platform == Platform.iOS)
{
takeScreenshot("Given that I'm on Document List screen, and there is a document already on the list, when I tap and swipe left the document name");
app.SwipeRightToLeft("doc1");
app.WaitForElement("Delete", "'Delete' button didn't appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then 'Delete' button should appear to the right of the document name. When I tap the delete button");
}
app.Tap("Delete");
app.WaitForNoElement("doc1", "Document 'doc1' is still on the list of documents, but it was supposed to be deleted!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then the document should be removed from the list");
}

[Test]
public void TestCheckForRequiredFields()
{
checkFields("required");
}

[Test]
public void TestValidationCheckRequiredFields()
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
takeScreenshot("Given that I'm on the New Document screen");
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));

List<string> listOfRequiredFields = getListOfRequiredFields();
app.Back();

//fill everything EXCEPT the given required field

foreach (string requiredFieldName in listOfRequiredFields)
{
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");

string requiredFieldEntry = requiredFieldName.Replace(" ", string.Empty) + "_Entry";

if (String.Compare(requiredFieldEntry, "Subject_Entry") != 0)
{
app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.EnterText("Subject_Entry", "doc1");
}

if (String.Compare(requiredFieldEntry, "Attachments_Entry") != 0)
{
app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Attachments_Entry");
//AddPhotoAttachment();
}

if (String.Compare(requiredFieldEntry, "Description_Entry") != 0)
{
app.WaitForElement("Description_Entry", "Description Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.EnterText("Description_Entry", "exampleDescription");
app.DismissKeyboard();

if (this._platform == Platform.iOS)
{
app.Tap("Description_Entry");
app.DismissKeyboard();
}
}


if (String.Compare(requiredFieldEntry, "SelectionPlace_Entry") != 0)
{
app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry"), "Selection Place Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("SelectionPlace_Entry");
app.Tap("SelectionPlace_Entry");

app.WaitForElement("searchingListTest", "List of buildings did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Building A");
}

if (String.Compare(requiredFieldEntry, "AuswahlType_Entry") != 0)
{
app.WaitForElement(c => c.All().Marked("AuswahlType_Entry"), "Auswahl Type Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("AuswahlType_Entry");
app.Tap("AuswahlType_Entry");

app.WaitForElement("searchingListTest", "List of Auswahl Types did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Defect");
}

if (String.Compare(requiredFieldEntry, "Latitude_Entry") != 0)
{
app.WaitForElement(c => c.All().Marked("Latitude_Entry"), "Latitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Latitude_Entry");
app.EnterText("Latitude_Entry", "23.23252");
app.DismissKeyboard();
}

if (String.Compare(requiredFieldEntry, "Longitude_Entry") != 0)
{
app.WaitForElement(c => c.All().Marked("Longitude_Entry"), "Longitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Longitude_Entry");
app.EnterText("Longitude_Entry", "32.2652");
app.DismissKeyboard();
}

if (String.Compare(requiredFieldEntry, "RecordingDate/Time_Entry") != 0)
setDateInDatePicker(2016, 3, 12);

takeScreenshot("When I fill all fields except the '" + requiredFieldName + "' field");

//saving the document

app.WaitForElement("save", "Save button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("save");

//sending the document

if (String.Compare(requiredFieldEntry, "Subject_Entry") == 0)
{
if (this._platform == Platform.Android)
app.TouchAndHold(c => c.Class("ConditionalFocusLayout"));
else if (this._platform == Platform.iOS)
app.SwipeRightToLeft(c => c.Class("Xamarin_Forms_Platform_iOS_CellTableViewCell"));
}
else
{
if (this._platform == Platform.Android)
app.TouchAndHold("doc1");
else if (this._platform == Platform.iOS)
app.SwipeRightToLeft("doc1");
}


app.WaitForElement("Send", "SEND button did not appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("And I save the document and then try sending it to the server");
app.Tap("Send");

//checking for the validation message

if (this._platform == Platform.Android)
app.WaitForElement(c => c.Marked("message").Text("Required field is empty\n Required field missing exception"), "Validation error message did not appear when checking for '" + requiredFieldName + "' required field!", timeout: TimeSpan.FromSeconds(10));
else if (this._platform == Platform.iOS)
app.WaitForElement(c => c.Class("UILabel").Text("Required field is empty\n Required field missing exception"), "Validation error message did not appear when checking for '" + requiredFieldName + "' required field!", timeout: TimeSpan.FromSeconds(10));

takeScreenshot("Then the validation error message about empty required fields should appear");
app.WaitForElement("Ok", "OK button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Ok");

//deleting the document for the next loop run

if (String.Compare(requiredFieldEntry, "Subject_Entry") == 0)
{
if (this._platform == Platform.Android)
{
app.WaitForElement(c => c.Class("ConditionalFocusLayout"), "Document with empty subject did not appear!", timeout: TimeSpan.FromSeconds(10));
app.TouchAndHold(c => c.Class("ConditionalFocusLayout"));
}
else if (this._platform == Platform.iOS)
{
app.WaitForElement(c => c.Class("Xamarin_Forms_Platform_iOS_CellTableViewCell"), "Document with empty subject did not appear!", timeout: TimeSpan.FromSeconds(10));
app.SwipeRightToLeft(c => c.Class("Xamarin_Forms_Platform_iOS_CellTableViewCell"));
}

app.Tap("Delete");
}
else
{
app.WaitForElement("doc1", "doc1 document did not appear!", timeout: TimeSpan.FromSeconds(10));

if (this._platform == Platform.Android)
app.TouchAndHold("doc1");
else if (this._platform == Platform.iOS)
app.SwipeRightToLeft("doc1");

app.Tap("Delete");
}
}
}

[Test]
public void TestUploadDocument()
{
AddNewDocument();

if (this._platform == Platform.Android)
{
takeScreenshot("Given that I'm on the Document List screen and there is a document already on the list, when I tap and hold the document name");
app.TouchAndHold("doc1");
app.WaitForElement("Send", "'Send' button didn't appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then 'Send' button should appear on the upper bar. When I tap the send button");
}
else if (this._platform == Platform.iOS)
{
takeScreenshot("Given that I'm on Document List screen, and there is a document already on the list, when I tap and swipe left the document name");
app.SwipeRightToLeft("doc1");
app.WaitForElement("Send", "'Send' button didn't appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then 'Send' button should appear to the right of the document name. When I tap the send button");
}

app.Tap("Send");
app.WaitForElement("progressPageTest", "The progress bar didn't appear!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("Then the progress bar should appear. When the upload finishes");
app.WaitForElement("Document \"doc1\" was sent", "The message about sending document success didn't appear!", timeout: TimeSpan.FromSeconds(60));
takeScreenshot("Then the confirmation message should appear");
app.Tap("Ok");
app.WaitForNoElement("doc1", "Document is still on the list but it's not supposed to be!", timeout: TimeSpan.FromSeconds(10));
takeScreenshot("And the document should be gone from the list of documents");
}

[Test]
public void TestShowHidePasswordSwitch()
{
takeScreenshot("Given that I'm on the login screen");
ClickButtonWithServers();
SelectServerTP();
TestWriteLoginAndPassword(testUser, testPass);

if (this._platform == Platform.iOS)
app.WaitForElement(c => c.All().Marked("passwordEntryTest").Descendant().Text("⦁⦁⦁⦁⦁⦁⦁⦁"), "Password is visible, but it's supposed to be hidden!", timeout: TimeSpan.FromSeconds(10));

takeScreenshot("When I fill in the credentials, then the password should be initially hidden. When I tap the 'Show password' switch");
app.WaitForElement(c => c.All().Marked("switchPasswordButtonTest"), "Show password switch didn't appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("switchPasswordButtonTest");

if (this._platform == Platform.Android)
app.WaitForElement(c => c.All().Marked("passwordEntryTest").Text(testPass), "Password is hidden, but it's supposed to be visible!", timeout: TimeSpan.FromSeconds(10));
else if (this._platform == Platform.iOS)
app.WaitForElement(c => c.All().Marked("passwordEntryTest").Descendant().Class("UITextFieldLabel").Text(testPass), "Password is hidden, but it's supposed to be visible!", timeout: TimeSpan.FromSeconds(10));

takeScreenshot("Then the password should become visible. When I tap the LOGIN button now");

ClickLoginButton();
app.WaitForElement("projectslistViewTest", "Projects list did not appear!", timeout: TimeSpan.FromSeconds(300));
takeScreenshot("Then it should be possible to login with a visible password");
}

[Test]
public void TestSearchingList()
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");

app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry"), "Selection Place Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("SelectionPlace_Entry");
app.Tap("SelectionPlace_Entry");

takeScreenshot("Given that I'm on the Selection Place choice screen");

//searching Selection Places

app.WaitForElement("SearchingBarTest", "Searching bar did not appear!", timeout: TimeSpan.FromSeconds(10));

searchOnTheList("Building A", "selectionPlace");
searchOnTheList("Building B", "selectionPlace");
searchOnTheList("Building C", "selectionPlace");
searchOnTheList("Building", "selectionPlace");
searchOnTheList("something", "selectionPlace");

//Going back and switching to Auswahl Entry

if (this._platform == Platform.Android)
{
app.Back();
app.Back();
}
else if (this._platform == Platform.iOS)
app.Back();

app.WaitForElement(c => c.All().Marked("AuswahlType_Entry"), "Auswahl Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("AuswahlType_Entry");
app.Tap("AuswahlType_Entry");

//searching Auswahl Types

app.WaitForElement("SearchingBarTest", "Searching bar did not appear!", timeout: TimeSpan.FromSeconds(10));

takeScreenshot("Switching to Auswahl Types list");

searchOnTheList("Just for Documentation", "auswahlType");
searchOnTheList("Defect", "auswahlType");
searchOnTheList("Security", "auswahlType");
searchOnTheList("rubbish", "auswahlType");
searchOnTheList("important", "auswahlType");
searchOnTheList("something", "auswahlType");
}

[Test]
public void TestFetchServerInstances()
{
string[] listOfServers = { "German instance / Deutschland", "internal", "Test-instance-Development" };

takeScreenshot("Given that I'm on the login screen, when I tap the 'Server' button");
ClickButtonWithServers();

foreach (string serverName in listOfServers)
{
app.WaitForElement(c => c.All().Marked(serverName), "Server '" + serverName + "' did not appear!", timeout: TimeSpan.FromSeconds(20));
}

takeScreenshot("Then the list of fetched server instances should appear");

foreach (string serverName in listOfServers)
{
app.Tap(serverName);
AssertLabelHasText("choseServerButtonTest", serverName, "The correct selected server (" + serverName + ") is not visible in Server button!");
takeScreenshot("When I tap the '" + serverName + "' server, it should appear in the Server button");
ClickButtonWithServers();
}
}

private void searchOnTheList(string searchPhrase, string typeOfList)
{
string[] selectionPlaces = { "Building A", "Building B", "Building C" };
string[] auswahlTypes = { "Just for Documentation", "Defect", "Security", "rubbish", "important" };

app.EnterText("SearchingBarTest", searchPhrase);
app.PressEnter();
app.DismissKeyboard();

string[] usedArray = null;

if (0 == String.Compare("selectionPlace", typeOfList))
usedArray = selectionPlaces;
else if (0 == String.Compare("auswahlType", typeOfList))
usedArray = auswahlTypes;

foreach (string str in usedArray)
{
if (str.StartsWith(searchPhrase))
app.WaitForElement(c => c.Marked("searchingListTest").Descendant().Text(str), "Element '" + str + "' is not on the list but it was supposed to be!", timeout: TimeSpan.FromSeconds(10));
else
app.WaitForNoElement(c => c.Marked("searchingListTest").Descendant().Text(str), "Element '" + str + "' is on the list but it was not supposed to be!", timeout: TimeSpan.FromSeconds(10));
}

takeScreenshot("When I search for the '" + searchPhrase + "' phrase, then all the matching elements should appear on the list, and the non-matching elements should be hidden");

app.ClearText("SearchingBarTest");
}

private void AssertLabelHasText(string automationId, string message, string assertionMessage)
{
app.WaitForElement(c => c.Marked(automationId).Marked(message));
}

private void TestWriteLoginAndPassword(string login, string password)
{
WriteStringToUsername(login);
WriteStringToPassword(password);
app.DismissKeyboard();
}

private void ClickLoginButton()
{
app.WaitForElement("ClickedLoginButtonTest", "Login button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("ClickedLoginButtonTest");
}

private void ClickButtonWithServers()
{
app.WaitForElement("choseServerButtonTest", "Choose server button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("choseServerButtonTest");
}

private void WriteStringToUsername(string s)
{
app.WaitForElement("usernameEntryTest", "Username text field did not appear!");
app.ClearText("usernameEntryTest");
app.EnterText("usernameEntryTest", s);
app.DismissKeyboard();
}

private void WriteStringToPassword(string s)
{
app.WaitForElement("passwordEntryTest", "Password text field did not appear!");
app.ClearText("passwordEntryTest");
app.EnterText("passwordEntryTest", s);
}

private void SelectServerTP()
{
app.WaitForElement(c => c.All().Marked("Test-instance-Development"), "Server 'Test-instance-Development' did not appear!", timeout: TimeSpan.FromSeconds(20));
app.Tap("Test-instance-Development");
AssertLabelHasText("choseServerButtonTest", "Test-instance-Development", "The correct selected server is not visible in Server button!");
}

private void LoginAndChooseDocumentType()
{
LoginAndChooseProject();
app.WaitForElement("Photo Documentation", "Photo Documentation button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Photo Documentation");
app.WaitForElement("documentsListViewTest", "Document List did not appear!", timeout: TimeSpan.FromSeconds(10));
}

private void LoginAndChooseProject()
{
ClickButtonWithServers();
SelectServerTP();
TestWriteLoginAndPassword(testUser, testPass);
ClickLoginButton();
app.WaitForElement("projectslistViewTest", "Projects List did not appear!", timeout: TimeSpan.FromSeconds(300));
app.Tap("Template für FotoPusher");
app.WaitForElement("documentsTypelistViewTest", "Document Type list did not appear!", timeout: TimeSpan.FromSeconds(10));
}


private void LoginAndAddPhotoAttachment()
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Attachments_Entry");
//app.WaitForElement("Take a photo", "'Take a photo' button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Take a photo");
//app.WaitForElement("ImageAttachementListTest", "Attachments list list did not appear!", timeout: TimeSpan.FromSeconds(15));
//app.WaitForElement("photostub_1", "Photo wasn't added to the list of attachments!", timeout: TimeSpan.FromSeconds(10));
}

private void AddPhotoAttachment()
{
app.WaitForElement("Take a photo", "'Take a photo' button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Take a photo");
}

private void AddNewDocument()
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");

//Filling the data

app.WaitForElement("Subject_Entry", "Document Subject text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.EnterText("Subject_Entry", "doc1");

app.WaitForElement("Attachments_Entry", "Attachments button did not appear!", timeout: TimeSpan.FromSeconds(10));
//app.Tap("Attachments_Entry");
//AddPhotoAttachment();

app.WaitForElement("Description_Entry", "Description Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.EnterText("Description_Entry", "exampleDescription");
app.DismissKeyboard();

app.WaitForElement(c => c.All().Marked("SelectionPlace_Entry"), "Selection Place Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("SelectionPlace_Entry");
app.Tap("SelectionPlace_Entry");
app.WaitForElement("searchingListTest", "List of buildings did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Building A");

app.WaitForElement(c => c.All().Marked("AuswahlType_Entry"), "Auswahl Type Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("AuswahlType_Entry");
app.Tap("AuswahlType_Entry");
app.WaitForElement("searchingListTest", "List of Auswahl Types did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("Defect");

app.WaitForElement(c => c.All().Marked("Latitude_Entry"), "Latitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Latitude_Entry");
app.EnterText("Latitude_Entry", "23.23252");
app.DismissKeyboard();
app.WaitForElement(c => c.All().Marked("Longitude_Entry"), "Longitude Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("Longitude_Entry");
app.EnterText("Longitude_Entry", "32.2652");
app.DismissKeyboard();
setDateInDatePicker(2016, 3, 12);
app.WaitForElement("save", "Save button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("save");
app.WaitForElement("doc1", "Added document doc1 did not appear on the list!", timeout: TimeSpan.FromSeconds(10));
app.Back();
app.Tap("Photo Documentation");
app.WaitForElement("documentsListViewTest", "Document list did not appear!", timeout: TimeSpan.FromSeconds(10));
app.WaitForElement("doc1", "Added document doc1 did not appear on the list!", timeout: TimeSpan.FromSeconds(10));
}

private void takeScreenshot(string description)
{
string locale = System.Environment.GetEnvironmentVariable("XTC_LOCALE");

if (0 != String.Compare(locale, "en_GB"))
{
app.Screenshot(description);
}
}

private void setDateInDatePicker(int year, int month, int day)
{
app.WaitForElement(c => c.All().Marked("RecordingDate/Time_Entry"), "Recording Date/Time Entry text field did not appear!", timeout: TimeSpan.FromSeconds(10));
app.ScrollDownTo("RecordingDate/Time_Entry");
app.Tap("RecordingDate/Time_Entry");

DateTime date = new DateTime(year, month, day);

int mnth;
if (this._platform == Platform.Android)
{
mnth = date.Month - 1;
app.WaitForElement("datePicker", "Date Picker did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Query(c => c.Marked("datePicker").Invoke("updateDate", date.Year, mnth, date.Day));
app.WaitForElement("OK", "OK button in Date Picker did not appear", timeout: TimeSpan.FromSeconds(10));
app.Tap("OK");
}
else if (this._platform == Platform.iOS)
{
mnth = date.Month;
string yearStr = "" + date.Year;
string monthStr = date.ToString("MMMM");
string dateStr = "" + date.Day;

app.ScrollDownTo(x => x.Text(monthStr), x => x.Class("UIPickerTableView").Index(0));
app.Tap(x => x.Text(monthStr));
app.ScrollDownTo(x => x.Text(dateStr), x => x.Class("UIPickerTableView").Index(3));
app.Tap(x => x.Text(dateStr));
app.ScrollUpTo(x => x.Text(yearStr), x => x.Class("UIPickerTableView").Index(6));
app.Tap(x => x.Text(yearStr));
app.Tap("Done");
}
}

//Possible values: "visible" and "required"
private void checkFields(string checkVisibleOrRequired)
{
LoginAndChooseDocumentType();
app.WaitForElement("add", "ADD button did not appear!", timeout: TimeSpan.FromSeconds(10));
app.Tap("add");
app.WaitForElement("Subject_Entry", "Subject_Entry is required but not marked with a red star!", timeout: TimeSpan.FromSeconds(10));

string jSONWithFields = (string)Invoke("GetInfoAboutFields");
JsonStructureForTestOnly jSonStructure = JsonConvert.DeserializeObject<JsonStructureForTestOnly>(jSONWithFields);

List<string> visibleFieldNames = new List<string>();
List<string> invisibleFieldNames = new List<string>();
List<string> requiredFieldNames = new List<string>();

foreach (var field in jSonStructure.fields)
{
string fieldName = field.name;
string isFieldVisible = field.visible;
string isFieldRequired = field.required;

if (0 == String.Compare(checkVisibleOrRequired, "visible")) //if we are checking for visible fields
{
if (0 == String.Compare(isFieldVisible, "true"))
{
if (0 == String.Compare(isFieldRequired, "true"))
{
app.WaitForElement(c => c.All().Marked(fieldName + "*"), fieldName + " field is invisible but it was supposed to be visible!", timeout: TimeSpan.FromSeconds(10));
}
else
{
app.WaitForElement(c => c.All().Marked(fieldName), fieldName + " field is invisible but it was supposed to be visible!", timeout: TimeSpan.FromSeconds(10));
}

string entryName = fieldName.Replace(" ", string.Empty) + "_Entry";
app.WaitForElement(c => c.All().Marked(entryName), entryName + " field is invisible but it was supposed to be visible!", timeout: TimeSpan.FromSeconds(10));

visibleFieldNames.Add(fieldName);
}
else
{
if (0 == String.Compare(isFieldRequired, "true"))
{
app.WaitForNoElement(c => c.All().Marked(fieldName + "*"), fieldName + " field is visible but it was supposed to be invisible!", timeout: TimeSpan.FromSeconds(10));
}
else
{
app.WaitForNoElement(c => c.All().Marked(fieldName), fieldName + " field is visible but it was supposed to be invisible!", timeout: TimeSpan.FromSeconds(10));
}

string entryName = fieldName.Replace(" ", string.Empty) + "_Entry";
app.WaitForNoElement(c => c.All().Marked(entryName), entryName + " field is visible but it was supposed to be invisible!", timeout: TimeSpan.FromSeconds(10));

invisibleFieldNames.Add(fieldName);
}
}
else if (0 == String.Compare(checkVisibleOrRequired, "required")) //if we are checking for required fields
{
if (0 == String.Compare(isFieldRequired, "true"))
{
app.WaitForElement(c => c.All().Marked(fieldName + "*"), fieldName + " field is required but not marked with a red star!", timeout: TimeSpan.FromSeconds(10));
requiredFieldNames.Add(fieldName);
}
else
{
app.WaitForNoElement(c => c.All().Marked(fieldName + "*"), fieldName + " field is not required but it's with a red star!", timeout: TimeSpan.FromSeconds(10));
}
}
}

if (0 == String.Compare(checkVisibleOrRequired, "visible"))
takeScreenshot("Given that I'm on the New Document screen, then I shall see following fields: '" + String.Join(",", visibleFieldNames) + "', and: '" + String.Join(",", invisibleFieldNames) + "' fields shall not be displayed");
else if (0 == String.Compare(checkVisibleOrRequired, "required"))
takeScreenshot("Given that I'm on the New Document screen, then I should see that all the required fields i.e: " + String.Join(",", requiredFieldNames) + "are marked with a red star");
}

public class OneFieldForTestOnly
{
public string name { get; set; }
public string visible { get; set; }
public string required { get; set; }
}
public class JsonStructureForTestOnly
{
public List<OneFieldForTestOnly> fields { get; set; }
}

private List<string> getListOfRequiredFields()
{

string jSONWithFields = (string)Invoke("GetInfoAboutFields");

JsonStructureForTestOnly jSonStructure = JsonConvert.DeserializeObject<JsonStructureForTestOnly>(jSONWithFields);

List<string> requiredFieldNames = new List<string>();

foreach (var field in jSonStructure.fields)
{
string fieldName = field.name;
string isFieldRequired = field.required;

if (0 == String.Compare(isFieldRequired, "true"))
{
requiredFieldNames.Add(fieldName);
}
}
return requiredFieldNames;
}

private List<string> getListOfAllVisibleFields()
{
string jSONWithFields = (string)Invoke("GetInfoAboutFields");
JsonStructureForTestOnly jSonStructure = JsonConvert.DeserializeObject<JsonStructureForTestOnly>(jSONWithFields);

List<string> visibleFieldNames = new List<string>();

foreach (var field in jSonStructure.fields)
{
string fieldName = field.name;
string isFieldVisible = field.visible;

if (0 == String.Compare(isFieldVisible, "true"))
{
visibleFieldNames.Add(fieldName);
}
}
return visibleFieldNames;
}
}
}