Skip to content

Instantly share code, notes, and snippets.

@niks551
Created March 4, 2014 19:21
Show Gist options
  • Save niks551/9353652 to your computer and use it in GitHub Desktop.
Save niks551/9353652 to your computer and use it in GitHub Desktop.
Questions Simulation
package com.salesforce.mobile.suit.tests._190.phone.pone;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import com.salesforce.mobile.suit.core.Constants.Layout;
import com.salesforce.mobile.suit.core.Constants.Wait;
import com.salesforce.mobile.suit.core.TestRunner;
import com.salesforce.mobile.suit.tests.TestCase;
/**
* @author Nikhilesh Reddy Chaduvula<nchaduvula@salesforce.com> Team: Perfomance Service Cloud
* Date:Feb 25 2014
*
*/
public class ServiceCloudBackend_Plus_Phone_190 extends TestCase {
private static Logger log = Logger.getLogger(ServiceCloudBackend_Plus_Phone_190.class);
String user;
String _layout;
Wait _wait;
/*
* Run script that we want to run using this
*
* (non-Javadoc)
*
* @see
* com.salesforce.mobile.suit.tests.TestCase#runScript(com.salesforce.mobile.suit.core.TestRunner)
*/
@Override
public void runScript(TestRunner _testRunner) throws Exception {
user = _testRunner.getTest().getUsername();
_wait = _testRunner.getTest().getWait();
_layout = "na";
String _account = "na", _contact = "na", _opportunity = "na", _lead = "na", _case = "na";
String _task = "na";
String tabIndex;
if (user.contains("admin@190.org62.org")) {
_layout = Layout.SalesCloudDBLoad;
_account = "Account_10000_12137";
_contact = "F_4191_11496 L_10000_8092";
_opportunity = "B-Y-1_StandardField";
_lead = "Simon Butler 10_StandardField";
_case = "00001012";
_task = "MyTask_IP_High_Std_5";
} else if (user.contains("user2@mobile.perf.org")) {
_layout = Layout.MOD;
_account = "Account_50F1_1";
_contact = "Contact_50F1_1 Contact";
_opportunity = "Opportunity_50F1_1";
_lead = "Lead_50Field_FN_1 Lead_50dField_LN_1";
_case = "00001364";
_task = "MyTask_IP_High_50F_5";
} else if (user.contains("user3@mobile.perf.org")) {
_layout = Layout.EXT;
_account = "Account_200F1_1";
_contact = "Contact_200F1_1 Contact";
_opportunity = "Opportunity_200F1_1";
_lead = "Lead_200Field_FN_1 Lead_200Field_LN_1";
_case = "00001375";
_task = "MyTask_IP_High_200F_5";
} else if (user.contains("admin@mobile.perf.org")) {
_layout = Layout.SalesCloudCorsa;
_account = "Extra Space Storage Inc.8_StandardField";
_contact = "Mark Zuckerberg 1";
_opportunity = "B-Y-1_StandardField";
_lead = "Simon Butler 10_StandardField";
_case = "00001352";
_task = "MyTask_IP_High_Std_5";
}
// login to the app
_testRunner.login("/one/one.app", _testRunner.getTest().getUsername(), _testRunner.getTest()
.getPassword(), true);
// give atleast 15000 milliseconds /150 seconds why?
_testRunner.sleepAtLeast(15000);
// open + sign at the bottom right
_testRunner
.clickWait(
"Open + sign",
_wait.low(),
By.xpath("//p[contains(@class,'publisherActivator')]//a[contains(@class,'publisherActivator')][@title='Open Publisher']"));
// Open the second tab/page or second page not consistent depends on device currently on iphone
// 5
_testRunner.clickWait("Open the second tab", _wait.low(), By.xpath("//a[@title='Page 3']"));
// Better to use this xpath for testing
// html//body//div[4]//div[1]//section//div[2]//div[1]//div[1]//article//nav//ul//li[3]
// div[@class='cuf-landscape']//article[@role='article']//nav[@class='carousel-nav-container
// carousel-nav-position-bottom'][@role='tablist']//ul[@class='carousel-nav-items
// uiCarouselPageIndicator'][@role='presentation']//li[3]
// //html//body//div[4]//div[1]//section//div[2]//div[1]//div[1]//article//nav//ul//li[3]
// Be careful this is dangerous there are 2 elements and we are selecting based on text
_testRunner.clickWait("Click On question", _wait.low(),
By.xpath("//span[@class='entity-label'][text()='Question']"));
// dev-Please don't change the place holder
// There has to be unique text in the question name
_testRunner
.inputWait(
"Input Question",
UUID.randomUUID().toString(),
By.xpath("//input[@class='inputField cuf-questionTitleField uiInput uiInputText'][@placeholder='What would you like to know?']"));
// dev-Please don't change the place holder
_testRunner.inputWait("Input text in text area",
"Only God and me Knows this testing and now only he knows",
By.xpath("//textarea[@placeholder='Add details about your question...']"));
// dev-please don't change Ask
_testRunner.clickWait("Click On Ask", _wait.low(),
By.xpath("//span[@class=' label bBody truncate'][text()='Ask']"));
_testRunner.executeJSRaw("window.localStorage.clear()", _wait.low());
_testRunner.logout();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment