So I am doing a search GUI for full pc systems. The button Get Info is the action button that retrieves the values from the MySQL database and puts them in the jTextfields, but when I press on Get Info, nothing happends, and no errors.  This is the method that gets all the info, and the method is located in class DBAccess which contains all the SQL methods + the connection to database.    public SQLException getpc(fullpc fp) {         ResultSet rs;         connect ();         try {             rs = stmt.executeQuery("SELECT * FROM fullsystems WHERE Name = " + fp.name);             while(rs.next()) {                 fp.id = rs.getString("ID");                 fp.name = rs.getString("Name");                 fp.cpu = rs.getString("Processor");                 fp.gpu = rs.getString("Graphics");                 fp.ram = rs.getString("Memory");                 fp.p = rs.getString("Price");                 fp.quant = rs.getString("Available quantity");             }         }         catch (SQLException e) {             return e;         }         return null;     }     And this is the class that contains all the attributes of the table:    package area51project; public class fullpc {     public String id;     public String name;     public String cpu;     public String gpu;     public String ram;     public String mem;     public String p;     public String quant; }     And at last, the code that is put into the Get Info button:    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                   fullpc fp = new fullpc();         DBAccess db = new DBAccess();         fp.name = (String) jComboBox1.getSelectedItem();         db.getpc(fp);         cpu.setText(fp.cpu);         ram.setText(fp.ram);         storage.setText(fp.mem);         gpu.setText(fp.gpu);         price.setText(fp.p);         quantity.setText(fp.quant);               }      The jCombobox1 is just the combobox that is near the Get Info button, so I choose the name of the PC, and then pressing the button shows the info of that PC in the jTextfields. However, Price and Quantity are shown in jLabels.  Help?
121
I always thought Java uses pass-by-reference. However, I've seen a couple of blog posts (for example, ) that claim that it isn't (the blog post says that Java uses pass-by-value). I don't think I understand the distinction they're making. What is the explanation?
92671
public class ExampleClass {       public static void publishCaseUpdateNotifications(List&lt;Case&gt; cases) {     List&lt;Case_Updated__e&gt; notifications = new List&lt;Case_Updated__e&gt;();     for (Case c: cases) {         notifications.add(new Case_Updated__e(             Case__c = (String)c.Id,             CreatedByName__c = UserInfo.getName(),             CaseNumber__c = c.CaseNumber         ));     }       List&lt;Database.SaveResult&gt; results = EventBus.publish(notifications);      for (Database.SaveResult result : results) {         if (!result.isSuccess()) {             for (Database.Error error : result.getErrors()) {                 System.debug('Error returned: ' +                     error.getStatusCode() +' - '+                     error.getMessage());             }         }       }      }    }   My Test Class: getting error   @isTest   public class ExampleTestClass {    @isTest   static void testClassforExample(){         Case testcase = new Case(Subject ='Test',);      list&lt;Case_Updated__e&gt; caseUpdate =      ExampleClass.publishCaseUpdateNotifications(testcase );       }      }   My Error is Method does not exist or incorrect signature: void publishCaseUpdateNotifications(Case) from the type ExampleTestClass   Please suggest me how to resolve this error.     trigger Cases on Case (after insert) { if(Trigger.isAfter) {     System.debug('I will be replaced shortly!'); }  }   Do we need test class for above trigger. Please suggest me too
85933
I was writing a toString() for a class in Java the other day by manually writing out each element of the class to a String and it occurred to me that using reflection it might be possible to create a generic toString() method that could work on ALL classes. I.E. it would figure out the field names and values and send them out to a String.  Getting the field names is fairly simple, here is what a co-worker came up with:  public static List initFieldArray(String className) throws ClassNotFoundException {      Class c = Class.forName(className);     Field field[] = c.getFields();     List&lt;String&gt; classFields = new ArrayList(field.length);      for (int i = 0; i &lt; field.length; i++) {         String cf = field[i].toString();         classFields.add(cf.substring(cf.lastIndexOf(".") + 1));     }      return classFields; }   Using a factory I could reduce the performance overhead by storing the fields once, the first time the toString() is called. However finding the values could be a lot more expensive.  Due to the performance of reflection this may be more hypothetical then practical. But I am interested in the idea of reflection and how I can use it to improve my everyday programming.
16290
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through the resources here and use them to shape more specific questions. To browse all canonical questions and answers, navigate to the  tag. This question and answer is owned by the community! If you can improve it and make it more useful, you're welcome to edit it. I am building a trigger, a unit test, or other Apex code. I'm working with sObject records, and trying to access related record information. For example, I might have a structure like this: Account a = new Account(Name = 'Test'); insert a;  Opportunity o = new Opportunity(Name = 'Donation', AccountId = a.Id); insert o;  System.assertEquals(o.Account.Name, 'Test', 'Correct Account associated'); // Assertion fails!  Or, in a trigger, I might be aiming for something like this: trigger ContactTrigger on Contact (after insert) {     for (Contact c : Trigger.new) {         if (c.Account.Name == 'Test') {             // Take some action here         }      } }  Why doesn't this work? Why am I getting null values, or NullPointerExceptions?
57295
I have a Trigger that is referencing a class. It works in Dev, but now I am trying to create the test class in order to push it to production. I am trying to test that a new user is created. I keep getting the same error System.QueryException: List has no rows for assignment to SObject. The error seems to point to the class on line 9 where the Account is added. The goal of the code is when a new user is inserted, then a contact for that new user is created as well. Does someone have any ideas why this is happening? I've used the Query Editor to make sure that the record does exist, and it does, so I'm stumped. Thanks in advance for the help.   Trigger      trigger UserInsertContactInsert1 on User (after insert, after update) {      if(Trigger.isAfter &amp;&amp; Trigger.isInsert){         Set&lt;ID&gt; usrIds = new Set&lt;ID&gt;();          for(User u : Trigger.new){             usrIds.add(u.id);         }          UserContactSyncClass1.syncContact(usrIds);       }      if(Trigger.isAfter &amp;&amp; Trigger.isUpdate){          Set&lt;ID&gt; idSet = new Set&lt;ID&gt;();         Set&lt;ID&gt; idSet2 = new Set&lt;ID&gt;();          for(User u : trigger.new){             for(User r : trigger.old){                 if(u.ID == r.ID &amp;&amp; u.isActive==false &amp;&amp; r.isActive==true){                     idSet.add(u.ID);                 }                  if (u.ID == r.ID &amp;&amp; u.isActive==true &amp;&amp; r.isActive==false) {                     idSet2.add(u.ID);                 }              }         }          UserContactSyncClass1.InactiveContact(idSet);         UserContactSyncClass1.ActivateContact(idSet2);     } }   Class  public class UserContactSyncClass1 {      @future     public static void syncContact(Set&lt;Id&gt; userSet){         List&lt;Contact&gt; cList = new List&lt;Contact&gt;();         List&lt;User&gt; userList = [Select ID, FirstName, LastName, Email, Phone, True_Market_Unit__c, True_Market_Name__c FROM User WHERE ID IN :userSet];         List&lt;String&gt; mList = new List&lt;String&gt;();         List&lt;String&gt; mktList = new List&lt;String&gt;();         **Account acc = [SELECT Id, Name FROM Account WHERE Name = 'Company Users' Limit 1];**          // Loop through Users, to get List of True Market Number         for(User usr : userList){             mList.add(usr.True_Market_Unit__c);                 }          // Use the True Market Number and Match to the True Market Number in Markets         for(Market__c mkt : [SELECT Name, Unit_Number__c FROM Market__c WHERE Unit_Number__c IN :mList]){             mktList.add(mkt.Name);           }          for(User usr : userList){             for(String mk : mktList){                 usr.True_Market_Name__c = mk;             }             System.debug(usr.True_Market_Name__c);         }          for(User u : userList){             cList.add(new Contact(FirstName=u.FirstName, LastName=u.LastName, User_True_Market_Name__c=u.True_Market_Name__c, Email=u.Email, Phone=u.Phone, OwnerID=u.ID, Related_User__c=u.Id, AccountId = acc.Id));         }          upsert cList;     }   Test Class Method with the Error  public static testMethod void validateNewUser(){          Profile p = [SELECT id FROM Profile WHERE Name='System Administrator'];          User u = new User(             FirstName = 'test',              LastName= 'last_test',              Email='test323232@test.com',              Phone='111-111-1111',              True_Market_Unit__c='1111',              alias = 'test',              EmailEncodingKey='UTF-8',             ProfileId = p.Id,             LanguageLocaleKey='en_US',             LocaleSidKey='en_US',              TimeZoneSidKey='America/Los_Angeles',             UserName = 'test323232@test.com'          );          System.runAs(u){             System.assertEquals('111-111-1111', u.Phone);         }      }   Updated Solution  Turns out even though my User never referenced the account, I still needed to insert it into my test class, with the Name='Company Users' from my SOQL query. Thanks everyone for all the help.
103246
I can't seem to call the objects out on the database and onto a visualforce page using this set up:   public with sharing class HarborEventController {  private final Event__c event; public HarborEventController(ApexPages.StandardController controller) {     this.eventlist = (Event__c)controller.getRecord(); }   public Integer eventcount{get;set;} public HarborEventController (){    eventcount = [SELECT COUNT() FROM Event__c];     }   public list&lt;Event__c&gt; mainlist {get;set;}   public list&lt;Event__c&gt; displayevents(){     mainlist = new list&lt;Event__c&gt;();     String mainsoql = 'SELECT Id, Name__C, Message__c, Display_Date__c, FROM Event__c';      mainsoql += 'ORDER BY Display_date__c LIMIT :5';     mainlist = Database.query(mainsoql);     return mainlist; }   and the visualforce page :           &lt;apex:composition template="eh_base"&gt;           &lt;apex:define name="heros-content"&gt;             &lt;/apex:define&gt;       &lt;apex:define name="content"&gt;        &lt;section id="services-sec"&gt;          &lt;div class="container"&gt;             &lt;div class="row" style="padding-top: 60px;"&gt;       &lt;apex:outputPanel layout="block" rendered="{!AND(NOT(ISNULL(mainlist)),mainlist.size&gt;0)}"&gt;         &lt;apex:form id="blockofeventtorepeat"&gt;             &lt;apex:repeat value="{!mainlist}" var="evententry" id="repeat"&gt;                 &lt;div class="col-md-9"&gt;                    &lt;h3&gt;&lt;apex:outputLink styleClass="evententry-header block" value="{!$Page.eh_eventdetails}?id={!evententry.id}"&gt;{!evententry.Name__c}&lt;/apex:outputLink&gt;&lt;/h3&gt;                     &lt;apex:outputPanel &gt;                      &lt;p&gt;                          &lt;img src="{!URLFOR($Action.Attachment.Download, evententry.Attachments[0].Id)}" class="pull-left img-responsive" alt="" style="max-width:180px;max-height:100px"/&gt;                         {!evententry.Message__c}                      &lt;/p&gt;                        &lt;apex:outputLink styleclass="btn btn-sm btn-default" value="{!$Page.eh_eventdetails}?id={!evententry.id}"&gt;Read More&lt;/apex:outputLink&gt;                      &lt;/apex:outputPanel&gt;                 &lt;/div&gt;                 &lt;/apex:repeat&gt;                 &lt;/apex:form&gt;                 &lt;/apex:outputPanel&gt;                   &lt;/div&gt;             &lt;/div&gt;                 &lt;/section&gt;           &lt;/apex:define&gt; &lt;/apex:composition&gt;     Can anyone suggest how I can able to get the event data from the query and display it on a visualforce page in a repeat tag? I've tried everything and it doesn't work.  I've already tried passing the query from an anonymous user and the results were as expected
48923
When using JDBC, I often come across constructs like    ResultSet rs = ps.executeQuery(); while (rs.next()) {     int id = rs.getInt(1);     // Some other actions }   I asked myself (and authors of code too) why not to use labels for retrieving column values:    int id = rs.getInt("CUSTOMER_ID");   The best explanation I've heard is something concerning performance. But actually, does it make processing extremely fast? I don't believe so, though I have never performed measurements. Even if retrieving by label would be a bit slower, nevertheless, it provide better readability and flexibility, in my opinion. So could someone give me good explanation of avoiding to retrieve column values by column index instead of column label? What are pros and cons of both approaches (maybe, concerning certain DBMS)?
23909
Looking for reviewers to suggest optimization and improvements, and to evaluate coding practices.  final class Variables {     private final int x;     private final int y;      Variables(int x2, int y2) {         this.x = x2;         this.y = y2;     }      public int getX() {         return x;     }      public int getY() {         return y;     }      @Override public String toString()  {          return "x = " + x + " y = " + y;     } }  public final class FindMissing {      private FindMissing() {};      /**  * Takes an input a sorted array with two variables that repeat in the  * range. Remaining variable are consecutive. and returns two variables that repeats  *   * eg: for a range of 1,2,3,4, a valid input is [1, 4], [1, 3] etc.  *   * @param a : the sorted array.  */ /*  * Why is start needed ?  * If start is not given then if a1 is empty how do we know if missing numbers were  * [1, 2] or [4, 5] ??.   */ public static Variables sortedConsecutiveTwoMissing (int[] a, int startOfRange) {     if (a == null) throw new NullPointerException("a1 cannot be null. ");      int low = startOfRange;     // calculating the highest value of the range. it needs to be 2 more than length since all elememts are consecutive.     int high = startOfRange + (a.length - 1) + 2;      int i = 0;     boolean foundX = false;     int x = 0;       while (i &lt; a.length) {         if (a[i] != low) {             if (foundX) {                 return new Variables(x, low);             } else {                 x = low;                 foundX = true;             }         } else {             i++;         }         low++;     }      return new Variables(x, high);  }  public static void main(String[] args) {         // unsortedConsecutiveTwoMissing         int[] a6 = {1, 4};         System.out.println("Expected 2 and 3, Actual " + sortedConsecutiveTwoMissing(a6, 1));         // unsortedConsecutiveTwoMissing         int[] a7 = {-4, -1};         System.out.println("Expected -3 and -2, Actual " + sortedConsecutiveTwoMissing(a7, -4));         int[] a8 = {-4, -3, -2, -1};         System.out.println("Expected 0 and 1, Actual " + sortedConsecutiveTwoMissing(a8, -4));         int[] a9 = {5};         System.out.println("Expected 4 and 6, Actual " + sortedConsecutiveTwoMissing(a9, 4));         }      }
3927
I'm trying to set a variable inside my controller via an actionFunction, which is called by some Javascript, which is initially called by either by an actionPanel (with styleClass='btn') or a commandButton.  If the caller is the actionPanel then the variable updates reliably. However with the commandButton I can see the updated value flash briefly before reverting to its previous value. Maybe one out of every six clicks of the button actually causes the new value to stick. Sometimes it can take a dozen or more tries, regardless of click frequency.  Can someone please explain what's going on here?  PAGE  &lt;apex:page controller="MyController"&gt;     &lt;apex:form &gt;         &lt;apex:outputPanel id="panel"&gt;             &lt;apex:outputText value="MyString = {!MyString}"/&gt;             &lt;apex:actionFunction name="SetString" rerender="panel"&gt;                 &lt;apex:param name="param1" value="" assignTo="{!MyString}"/&gt;             &lt;/apex:actionFunction&gt;             &lt;script&gt;                 function JSetString() {                     SetString('{!MyString}' + '.');                 }             &lt;/script&gt;             &lt;apex:outputPanel onclick="JSetString()" styleClass="btn"&gt;                 Grow {!MyString} (works)             &lt;/apex:outputPanel&gt;             &lt;apex:commandButton onclick="JSetString()" value="Grow {!MyString} (unreliable)" rerender="panel"/&gt;         &lt;/apex:outputPanel&gt;     &lt;/apex:form&gt; &lt;/apex:page&gt;   CONTROLLER  global class MyController {      public MyController() { MyString = 'hello'; }      public String MyString {get;set;} }
91517
public static void handleCaseComment(CaseComment caseComment) {    User[] users = [SELECT LastName FROM User WHERE Id = caseComment.CreatedById LIMIT 1]; }   This gives me the following error:  unexpected token: 'caseComment.CreatedById'   How do I use the value of the variable caseComment.CreatedById in a SELECT statement?
48814
I am trying to save data to a database on a button push, but the variables seem to be private by the nature of where they are defined. I have tried to move where they are defined, but this seems to produce other errors.  Given a fix, why was it fixed that way?  The code follows.  namespace enable {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();             OleDbConnection favouriteConnection = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\\\192.168.123.5\\Share\\Matt\\BugTypes.mdb");             string strSQL = "SELECT CategoryName, Show " + "FROM [Categories] WHERE Show = 'Yes' " + "ORDER BY CategoryName";             OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL, favouriteConnection);             OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(adapter);             DataTable dTable = new DataTable();             adapter.Fill(dTable);             BindingSource bSource = new BindingSource();             bSource.DataSource = dTable;             dataGridView1.DataSource = bSource;             adapter.Update(dTable);         }         private void button1_Click(object sender, EventArgs e)         {             adapter.Update(dTable);//this is the button that needs to do the save, but can't see the variables.         }     } }
84342
I have a JFrame. This JFrame contains a JButton. I click the JButton and 10 JTextFields are created.  the problem: I cannot see them until "I force a repaint()" by resizing the window. Only then do I see the JTextFields created.  CODE:  JPanel points = new JPanel();  //Creating the JTextFields: for (int i=0; i&lt;10; i++) {     JTextField textField = new JTextField();     points.add(textField); }  repaint(); this.repaint(); super.repaint(); points.repaint();     THANK YOU - after the for loop, I just called points.validate() and it worked...
31406
I am planning to replace repeatedly executed Statement objects with PreparedStatement objects to improve performance. I am using arguments like the MySQL function now(), and string variables.   Most of the PreparedStatement queries I have seen contained constant values (like 10, and strings like "New York") as arguments used for the ? in the queries. How would I go about using functions like now(), and variables as arguments? Is it necessary to use the ?s in the queries instead of actual values? I am quite confounded.
18114
I have a method with an out parameter that tries to do a type conversion. Basically:  public void GetParameterValue(out object destination) {     object paramVal = "I want to return this. could be any type, not just string.";      destination = null; // default out param to null     destination = Convert.ChangeType(paramVal, destination.GetType()); }   The problem is that usually someone would call this like:  string output; GetParameterValue(output);   This will fail because of:  destination.GetType()   destination is null, so we can't call .GetType() on it. We also can not call:  typeof(destination)   because destination is a variable name not a type name.  So is there any way to get the type of an object that is set to null? I would think there would have to be a way to know what type a storage location is without it being assigned anything.    Just to give a bit more info, I am trying to make a utility method that will grab the output parameters of an Oracle stored procedure. The issue is that DbParameter.Value is of type object.  What would be ideal would be for the developers to do something like:  string val = GetParameterValue("parameterName");   The notable thing is that there is no casting of types. In practice, you don't know the lparam of the "equals", so I went with:  string val; GetParameterValue("parameterName", out val);   And figured within the method, I would know the destination type of the output variable. I guess that was a bad assumption. As an alternative, I also wrote the method:  public T GetParameterValue&lt;T&gt;(string paramName)   So the developers can do:  string val = GetParameterValue&lt;string&gt;("parameterName");   I find the explicit "string" declaration to be repetitive, especially since in practice, the destination if probably an object property and the oracle data type could change (think ORM):  MyObj.SomeProp = GetParameterValue&lt;MyObj.SomeProp.GetType()&gt;("parameterName");   But again, if MyObj.SomeProp is null, that .GetType() call fails. The VM has to know the type of MyObj.SomeProp, even when its null, right? or else how would it catch cast exceptions?    To partially solve my own problem, I can do:  MyObj.SomeProp = GetParameterValue&lt;typeof(MyObj).GetField("SomeProp").GetType()&gt;("parameterName");   The whole idea was to not have to explicitly use the Type in more than one place, so that if the data type changes, it only has to be changed in the destination object (MyObj.SomeProp) and in the DB. There has to be a better way...
61126
I am getting java.lang.NullPointerException while executing my test case , I am using Page Object Modle with PageFactory ,following are the code snippets  LoginPageObjec.java  public class LoginPageObjects {      @FindBy(xpath=".//*[@id='userName']")     private WebElement email;      @FindBy(xpath=".//*[@id='password']")     private WebElement password;      @FindBy(xpath=".//*[@id='loginFormSubmit']")     private WebElement loginBtn;      public void EnterUserName(String userName)     {         email.sendKeys(userName);     }      public void EnterPassword(String pass)     {         password.sendKeys(pass);     }      public void clickLogin()     {         loginBtn.click();     }   }   LoginTC.java  public class LoginTC extends BasePage{     private WebDriver driver;      @Test     public void login()     {         LoginPageObjects loginPage = PageFactory.initElements(driver, LoginPageObjects.class);         loginPage.EnterUserName("test.hr@domin.com.pk");         loginPage.EnterPassword("test");         loginPage.clickLogin();     } public void login1()         {             LoginPageObjects loginPage = PageFactory.initElements(driver, LoginPageObjects.class);             loginPage.EnterUserName("test.hr@domin.com.pk");             loginPage.EnterPassword("test");             loginPage.clickLogin();         }  }   BasePage.java  public class BasePage {     private WebDriver driver;      @BeforeMethod       public void initializeBrowser() {      driver=new FirefoxDriver();      driver.navigate().to("https://nexthrm-dev.vteamslabs.com/");      driver.manage().window().maximize();      }     @AfterMethod     public void closeBrowser()     {         driver.close();     }  }   I've extended BasePage class to utilize the (initialBrowser &amp; closeBrowser) functions in my test case but its producing nullpointer exception if I copy both of the functions (initialBrowser &amp; closeBrowser) into my LoginTC (testcase class) it works like charm but I dont want this redundant code i.e((initialBrowser &amp; closeBrowser) for all my testcases class could anyone explain why I am getting nullpointer exception
80694
I want to clear the inputtext used to search, and clear all search results using a commandbutton. I tried the following on the 'Reset' button I added but it only clears the inputtext and the search results are not clearing.  &lt;apex:pageBlockSectionItem &gt;                     &lt;apex:outputPanel layout="block" Rendered="true"&gt;                     &lt;apex:inputText value="{!ReportSearchString}" /&gt;                     &lt;apex:commandButton value="Search" action="{!searchReports}" reRender="ReportSearchResults, "/&gt; &amp;nbsp;&amp;nbsp;                      &lt;apex:commandButton value="Back" action="{!BackToCreateFeedPage}"/&gt;&amp;nbsp;                     &lt;apex:commandButton value="Reset" onclick="this.form.reset();return false;"/&gt;                     &lt;/apex:outputPanel&gt;                 &lt;/apex:pageBlockSectionItem&gt;                             &lt;/apex:pageBlockSection&gt;                         &lt;apex:pageBlockSection id="ReportSearchResults"&gt;                 &lt;apex:outputText value="{!warningMessage}" rendered="{!!showTable}" /&gt;                 &lt;apex:pageBlockTable value="{!reportList}" var="item" rendered="{!showTable}"&gt;                     &lt;apex:column headerValue="Report Name" &gt;                         &lt;apex:commandLink value="{!item.Name}" action="{!BackToCreateFeedPage}"&gt;                             &lt;apex:param value="{!item.Id}" name="SelectedReport" assignTo="{!selectedReportId}" /&gt;                         &lt;/apex:commandLink&gt;   This is my search function, it works fine. I need to clear the results of this search on clicking 'Reset' button.   public void searchReports()     {         showTable = false;               reportList = new List&lt;Report&gt;();          reportSearchResult = new Map&lt;Id, Report&gt;();          selectedReport = new Report();         if((ReportSearchString != null &amp;&amp; ReportSearchString != '') &amp;&amp; ReportSearchString.length() &gt;= 3)         {             reportSearchResult = new Map&lt;Id, Report&gt;([Select Id, Name From Report Where Name Like :'%'+ReportSearchString+'%' limit 2000]);              warningMessage = 'No Result Found';         }         else         {             warningMessage = 'Search text should have atleast 3 characters';         }     }
120241
I'm using data faker and I would like to know how to make my variables available in all steps of my test.  I wanted to leave all elements mapped in the initial step, or be given  WebDriver driver = new ChromeDriver();     //Mapping the elements  WebElement nomeusuario = driver.findElement(By.className("whsOnd zHQkBf"));   My main code is:  public class Criar_Conta_Gmail {  @Given("^que eu esteja na pagina principal do gmail\\.$") public void que_eu_esteja_na_pagina_principal_do_gmail() throws Throwable {     System.setProperty("webdriver.chrome.driver","C:\\Browsers\\chromedriver.exe");     WebDriver driver = new ChromeDriver();     driver.get("https://www.gmail.com");     driver.findElement(By.xpath("//span[contains(text(),'Criar conta')]")).click();     Thread.sleep(2000);     driver.findElement(By.xpath("//div[contains(text(),'Para mim')]")).click();     throw new PendingException();   }  @When("^criar uma nova conta com telefone invalido\\.$") public void criar_uma_nova_conta_com_telefone_invalido() throws Throwable {         WebDriver driver = new ChromeDriver();         //Mapping the elements      WebElement nomeusuario = driver.findElement(By.className("whsOnd zHQkBf"));      // sending data to the application     Faker faker = new Faker();     String Nome = faker.name().firstName();     nomeusuario.sendKeys(Nome);      throw new PendingException(); }  @Then("^o sistema não permite a finalização do cadastro\\.$") public void o_sistema_não_permite_a_finalização_do_cadastro() throws Throwable  {     // Write code here that turns the phrase above into concrete actions     throw new PendingException(); }