Selenium Mac Salesforce



  • I am trying to automate to log in into salesforce account and after it logs in i want it to click on contact button but for some reason it wont, i even wrote a different function just for it to click it but after it logs in it freezes in the same page after the screen maximizes. enter image description here

    And this is my code: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver;

    public class browser {
    public static void main(String[] args) throws InterruptedException {
    
        System.out.println("Start Test Case");
        initialize();
        LoginSFDC();
        WrongUNandPW();
        }
    
    
    
    
    private static WebDriver driver = null;
    
    public static void initialize() {
        System.setProperty("webdriver.chrome.driver", "chromedriver");
        driver = new ChromeDriver();
        }
    
    
    
    public static void LoginSFDC() throws InterruptedException {
    
    
        driver.get("https://login.salesforce.com/");
        driver.findElement(By.xpath("//input[@id='username']")).sendKeys("arnish.chakma-fliw@force.com");
        driver.findElement(By.xpath("//input[@id='password']")).sendKeys("lolboy845JJ");
    
        driver.findElement(By.xpath("//input[@id='rememberUn']")).click();
        driver.findElement(By.xpath("//input[@id='Login']")).click();
    
        driver.manage().window().maximize();
    
        WebElement contactbtn = driver.findElement(By.xpath("//a[@id='trial-subscribe-now']"));
        contactbtn.click();
    
    
    
    
        driver.close();
    
    
    
    }
    
    
    
    public static void WrongUNandPW() throws InterruptedException {
    
    
        driver.get("https://login.salesforce.com/");
    
        driver.findElement(By.xpath("//input[@id='username']")).sendKeys("arnish.chakma-fliw@force123.com");
        driver.findElement(By.xpath("//input[@id='password']")).sendKeys("lolboy845JJ123");
    
        driver.findElement(By.xpath("//input[@id='rememberUn']")).click();
        driver.findElement(By.xpath("//input[@id='Login']")).click();
    
    
    
        Thread.sleep(2000);
    
    
    
    }
    
    
    }
    

    Can someone help me find a solution for this thank you.



  • I see a google chrome notification there.

    You need to first handle/disable that notification first.

    To do that, you can use the following code snippet when initializing a browser

    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    .
    .
    .
    ChromeOptions cOptions = new ChromeOptions();
    System.setProperty("webdriver.chrome.driver", driverPath);
    cOptions.addArguments("--disable-notifications");
    WebDriver driver = new ChromeDriver(cOptions);
    

    --disable-notification will help you dismiss those notifications.

    If you want to disable infobars, you can use cOptions.addArguments("disable-infobars");



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2