How to login into Salesforce (Chrome) application using selenium webdriver and avoid identity verification)

前端 未结 2 932
不知归路
不知归路 2021-01-27 06:59

I try login to Salesforce whit this script, but it launches the page of verification of identity. The user and password are working, so how can I avoid the verification page?

相关标签:
2条回答
  • 2021-01-27 07:37

    To login into the Salesforce Web Application as the AUT is based on Lazy Loading you have to induce WebDriverWait for the elements to be clickable as follows:

    driver.get("https://test.salesforce.com/");
    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.input.username#username"))).sendKeys("RodrigoC");
    driver.findElement(By.cssSelector("input.input.password#password")).sendKeys("RodrigoC");
    driver.findElement(By.cssSelector("input.button.wide.primary")).click();
    
    0 讨论(0)
  • 2021-01-27 07:38

    To avoid identity verification, you can go to the Salesforce organization you're using and mark your IP as trusted. Once you do that, you will be able to log in without two-factor authentication for all future test runs (as long as they use the same IP).

    To mark your IP as trusted, go to Setup - Security Controls - Network Access.

    0 讨论(0)
提交回复
热议问题