2

I would like to know if there is any way around the Verification Code for Salesforce? I successfully login to Salesforce but, my script stops because of the Verification screen is there a way around this ?

I have selenium open a new Chrome window and navigate to http://test.salesforce.com

Note - I cannot change the IP range (the IT Department said "NO").

  • This does not involve two factor authentication. I believe it may be cookie related. Selenium is opening a new Chrome window and it may not have the cookie info (even though it was on the same computer). – llacey May 4 '16 at 18:40
  • What verification code screen are you talking about? Can you post a screenshot of it? – Doug B May 5 '16 at 8:40
3

The verification code mechanism exists for good reasons and improves the security of production data.

However in a dev org I often use the following approach to dissable all verificaiton codes, as it can prevent/slow down developers.

You can whitelist ALL IP ranges in Security Controls -> Network Access.

This takes a lot of time manually, luckily there is a Chrome Plugin that will do this for you. Once installed it adds a button to the Network Access Screen. Press the button and it will cycle through all ranges and add them!

enter image description here

Link to the developers page.

2

I think you are talking about the two factor authentication, which is asking you to enter a code as part of the login.

This can be switched off for a user or profile.

The permission is called "Two-Factor Authentication for User Interface Logins" and if it is checked then the code is required during login. If not then it is not.

enter image description here

So you should confirm with your IT Department that they are happy for you to change this permission in the Sandbox environment for the user you are using for testing.

Hope this helps.

  • I can't find this on the user level. Only the profile. Is that right? – Brohan Jan 17 at 18:44
0

Where is it saying that you cannot change your IP range? You should be able to just look at the user that selenium is using to access test.salesforce, identify that IP range, and whitelist a range that includes that IP. In Salesforce your IP whitelist range can include a max of a 7 CIDR block, so make sure you are not exceeding that when trying to whitelist.

0

You can try to use ChromeOptions to load a default profile of the user.

/* Storing the Chrome Profile Path in Chrome_Profile_Path variable. */
String Chrome_Profile_Path = "C:\\Users\\abcd\\AppData\\Local\\Google\\Chrome\\User Data";

/* Creating an instance of ChromeOptions (i.e objChrome_Profile) */
ChromeOptions Chrome_Profile = new ChromeOptions();

/* Disabling the chrome browser extensions */
Chrome_Profile.addArguments("chrome.switches","--disable-extensions"); 

/* Adding Chrome profile by .addArguments to objChrome_Profile  */
Chrome_Profile.addArguments("user-data-dir=" + Chrome_Profile_Path);

/*Initializing the Webdriver instance (i.e. driver) to open Chrome Browser and passing the Chrome Profile as argument */
driver = new ChromeDriver(Chrome_Profile);
0

Follow the step Setup -> Administration Setup -> Security Controls -> Network Access.

1.Click 'New' 2.set the start and end ip address as follows:

0.0.0.0 to 1.255.255.255 (Set the full Ip Address or your full network address)

After setting the start & end ip Now run your script you will not get any verification screen.

  • Note - I cannot change the IP range (the IT Department said "NO"). – Oleksandr Berehovskyi Jun 2 '17 at 6:21
  • Then create a test gmail account,use this account for login & by using selenium script login to test gmail account & pick verification code from there only. – Syed Ahtisham Ali Jun 2 '17 at 8:35
0

Users logging in to Salesforce from an unrecognized browser or device are prompted to verify their identity as a security measure. Usually it happens the first time and a cookie is stored.

But I am sure when we run the automation scripts, it deletes browser cookies for security purposes.

So we can add our Source IP (You can find here, Salesforce Setup > Users > Select your user > Scroll down to login History and you will find your Source IP) which you elude to Network Trusted IP Range as mentioned below.

Setup > Security > Network Access > Trusted IP range > Add your source IP.

Hope this helps. Cheers.!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.