| 9 | import com.force.data.dynamic.FakerDataFactory; |
| 10 | |
| 11 | public class SalesforceHooks extends ProjectHooks{ |
| 12 | |
| 13 | @BeforeMethod |
| 14 | public void zLogin() { |
| 15 | new LoginPage().doLogin(); |
| 16 | } |
| 17 | |
| 18 | public void typeInputField(String label, String value) { |
| 19 | type("//label[text()='"+label+"']/following::input[1]", value, label); |
| 20 | } |
| 21 | |
| 22 | public void typeInputInFrame(String label, String value) { |
| 23 | typeInFrame("//label[text()='"+label+"']/following::input[1]", value, label); |
| 24 | } |
| 25 | |
| 26 | public void chooseByText(String label, String value) { |
| 27 | clickAndChoose("//label[text()='"+label+"']/following::lightning-base-combobox[1]", "(//label[text()='"+label+"']/following::lightning-base-combobox[1]//lightning-base-combobox-item//span[text()='"+value+"'])[1]", value, label); |
| 28 | } |
| 29 | |
| 30 | public void chooseByTextInFrame(String label, String value) { |
| 31 | clickAndChooseInFrame("//label[text()='"+label+"']/following::lightning-base-combobox[1]", "(//label[text()='"+label+"']/following::lightning-base-combobox[1]//lightning-base-combobox-item//span[text()='"+value+"'])[1]", value, label); |
| 32 | } |
| 33 | |
| 34 | public void verifyMandatory(String label) { |
| 35 | verifyAttribute("(//label[text()='"+label+"']/following::td[1]//div[1])[1]", "class","requiredInput"); |
| 36 | } |
| 37 | |
| 38 | public void verifyMandatoryInFrame(String label) { |
| 39 | verifyAttributeInFrame("(//label[text()='"+label+"']/following::td[1]//div[1])[1]", "class","requiredInput"); |
| 40 | } |
| 41 | |
| 42 | public String createLeadUsingApi() { |
| 43 | |
| 44 | Map<String, String> headers = new HashMap<>(); |
| 45 | headers.put("Authorization", "Bearer "+getToken()); |
| 46 | headers.put("Content-Type", "application/json"); |
| 47 | |
| 48 | String firstName = FakerDataFactory.getFirstName(); |
| 49 | String lastName = FakerDataFactory.getLastName(); |
| 50 | String companyName = FakerDataFactory.getCompanyName(); |
| 51 | |
| 52 | String jsonBody = "{\n" |
| 53 | + " \"FirstName\": \""+firstName+"\",\n" |
| 54 | + " \"LastName\": \""+lastName+"\",\n" |
| 55 | + " \"Company\": \""+companyName+"\",\n" |
| 56 | + " \"LeadSource\" : \"Other\"\n" |
| 57 | + "}"; |
| 58 | |
| 59 | postRequest("Lead/", headers, jsonBody); |
| 60 | |
| 61 | return firstName; |
| 62 | } |
| 63 | |
| 64 | public String createAccountUsingApi() { |
| 65 | |
| 66 | Map<String, String> headers = new HashMap<>(); |
| 67 | headers.put("Authorization", "Bearer "+getToken()); |
| 68 | headers.put("Content-Type", "application/json"); |
nothing calls this directly
no outgoing calls
no test coverage detected