1

I am writing test cases using selenium in python for a website, and am having trouble finding the best way to pass a correct login for each scenario. Currently I am using a wait and manually typing in the account information every time:

@given('I wait for input of correct credentials')
    def step_impl(context):
        WebDriverWait(context.driver, 20).until( 
             expected_conditions.visibility_of_elements_located(
                BasePageLocators.SIDEBAR)
        )

Is there a better way without having to send the information in my code? Preferably one that involves no manual input

2 Answers 2

3

While this article was written specifically to address how to handle SauceLabs-related creds, there's no reason you can't use the same method.

You take the credentials and store it outside of your code, e.g. in a Windows Environment variable, some local file, or the like. That way people with access to your repo don't have access to your credentials. It also allows each user to set up their own local credentials so that everyone can use their own credentials without modifying the scripts.

Sign up to request clarification or add additional context in comments.

Comments

0

You can invoke send_keys() method directly once the WebDriverWait returns the element as follows:

WebDriverWait(context.driver, 20).until( 
    expected_conditions.visibility_of_elements_located(
        BasePageLocators.SIDEBAR).send_keys("Allan Blackmar")

3 Comments

how does this answer the question? The question asked about securely passing credentials without specifying them in code.
@CoreyGoldberg While I agree with you, I don't think the question is super clear what the actual issue is.
@JeffC the question isn't super clear, but it's clear enough to know this answer isn't related whatsoever

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.