how to hide password in selenium webdriver C#





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I am working with our website automation testing script.

We have some part-time staff members we like ask them to run this script to monitoring all our web service.



There is an secure problem before I give this to them to run, because they can see the user name and password inside of code. VS C# + SpecFlow and Selenium.



How can I hide them? Or, how can I ask them to input their own username + password?



[FindsBy(How = How.Id, Using = "userNameInput")]
private IWebElement loginUsername;

public void UserName()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("userNameInput")));
loginUsername.Click();
loginUsername.SendKeys("admin");
}

[FindsBy(How = How.Id, Using = "passwordInput")]
private IWebElement loginPassword;

public void Password()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("passwordInput")));
loginPassword.Click();
loginPassword.SendKeys("SAd@12340");
}


Thanks










share|improve this question

























  • hope that's not a real password...

    – JohnB
    Nov 27 '18 at 1:57











  • nope, it just randomly created example, thanks

    – Shiliang Fang
    Nov 27 '18 at 2:16











  • developers.perfectomobile.com/pages/…

    – Mate Mrše
    Nov 27 '18 at 9:54


















1















I am working with our website automation testing script.

We have some part-time staff members we like ask them to run this script to monitoring all our web service.



There is an secure problem before I give this to them to run, because they can see the user name and password inside of code. VS C# + SpecFlow and Selenium.



How can I hide them? Or, how can I ask them to input their own username + password?



[FindsBy(How = How.Id, Using = "userNameInput")]
private IWebElement loginUsername;

public void UserName()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("userNameInput")));
loginUsername.Click();
loginUsername.SendKeys("admin");
}

[FindsBy(How = How.Id, Using = "passwordInput")]
private IWebElement loginPassword;

public void Password()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("passwordInput")));
loginPassword.Click();
loginPassword.SendKeys("SAd@12340");
}


Thanks










share|improve this question

























  • hope that's not a real password...

    – JohnB
    Nov 27 '18 at 1:57











  • nope, it just randomly created example, thanks

    – Shiliang Fang
    Nov 27 '18 at 2:16











  • developers.perfectomobile.com/pages/…

    – Mate Mrše
    Nov 27 '18 at 9:54














1












1








1








I am working with our website automation testing script.

We have some part-time staff members we like ask them to run this script to monitoring all our web service.



There is an secure problem before I give this to them to run, because they can see the user name and password inside of code. VS C# + SpecFlow and Selenium.



How can I hide them? Or, how can I ask them to input their own username + password?



[FindsBy(How = How.Id, Using = "userNameInput")]
private IWebElement loginUsername;

public void UserName()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("userNameInput")));
loginUsername.Click();
loginUsername.SendKeys("admin");
}

[FindsBy(How = How.Id, Using = "passwordInput")]
private IWebElement loginPassword;

public void Password()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("passwordInput")));
loginPassword.Click();
loginPassword.SendKeys("SAd@12340");
}


Thanks










share|improve this question
















I am working with our website automation testing script.

We have some part-time staff members we like ask them to run this script to monitoring all our web service.



There is an secure problem before I give this to them to run, because they can see the user name and password inside of code. VS C# + SpecFlow and Selenium.



How can I hide them? Or, how can I ask them to input their own username + password?



[FindsBy(How = How.Id, Using = "userNameInput")]
private IWebElement loginUsername;

public void UserName()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("userNameInput")));
loginUsername.Click();
loginUsername.SendKeys("admin");
}

[FindsBy(How = How.Id, Using = "passwordInput")]
private IWebElement loginPassword;

public void Password()
{
WebDriverWait wait = new WebDriverWait(Browser.Driver, new TimeSpan(0, 0, 5));
wait.Until(ExpectedConditions.ElementIsVisible(By.Id("passwordInput")));
loginPassword.Click();
loginPassword.SendKeys("SAd@12340");
}


Thanks







c# selenium-webdriver specflow






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 1:50









Jimi

9,77542036




9,77542036










asked Nov 27 '18 at 1:33









Shiliang FangShiliang Fang

237




237













  • hope that's not a real password...

    – JohnB
    Nov 27 '18 at 1:57











  • nope, it just randomly created example, thanks

    – Shiliang Fang
    Nov 27 '18 at 2:16











  • developers.perfectomobile.com/pages/…

    – Mate Mrše
    Nov 27 '18 at 9:54



















  • hope that's not a real password...

    – JohnB
    Nov 27 '18 at 1:57











  • nope, it just randomly created example, thanks

    – Shiliang Fang
    Nov 27 '18 at 2:16











  • developers.perfectomobile.com/pages/…

    – Mate Mrše
    Nov 27 '18 at 9:54

















hope that's not a real password...

– JohnB
Nov 27 '18 at 1:57





hope that's not a real password...

– JohnB
Nov 27 '18 at 1:57













nope, it just randomly created example, thanks

– Shiliang Fang
Nov 27 '18 at 2:16





nope, it just randomly created example, thanks

– Shiliang Fang
Nov 27 '18 at 2:16













developers.perfectomobile.com/pages/…

– Mate Mrše
Nov 27 '18 at 9:54





developers.perfectomobile.com/pages/…

– Mate Mrše
Nov 27 '18 at 9:54












1 Answer
1






active

oldest

votes


















0














In C# you can save sensitive information in app.config file, like this:



  <appSettings>
<add key="ShopBaseUrl" value="http://automationpractice.com/index.php" />
</appSettings>


And then take this information, using this code:



System.Configuration.ConfigurationManager.AppSettings["ShopBaseUrl"]);


Which will return to you a value from app.config, which has key: ShopBaseUrl






share|improve this answer
























  • but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

    – Shiliang Fang
    Dec 21 '18 at 2:56











  • If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

    – Ukrainis
    Dec 21 '18 at 7:09












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491513%2fhow-to-hide-password-in-selenium-webdriver-c-sharp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














In C# you can save sensitive information in app.config file, like this:



  <appSettings>
<add key="ShopBaseUrl" value="http://automationpractice.com/index.php" />
</appSettings>


And then take this information, using this code:



System.Configuration.ConfigurationManager.AppSettings["ShopBaseUrl"]);


Which will return to you a value from app.config, which has key: ShopBaseUrl






share|improve this answer
























  • but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

    – Shiliang Fang
    Dec 21 '18 at 2:56











  • If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

    – Ukrainis
    Dec 21 '18 at 7:09
















0














In C# you can save sensitive information in app.config file, like this:



  <appSettings>
<add key="ShopBaseUrl" value="http://automationpractice.com/index.php" />
</appSettings>


And then take this information, using this code:



System.Configuration.ConfigurationManager.AppSettings["ShopBaseUrl"]);


Which will return to you a value from app.config, which has key: ShopBaseUrl






share|improve this answer
























  • but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

    – Shiliang Fang
    Dec 21 '18 at 2:56











  • If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

    – Ukrainis
    Dec 21 '18 at 7:09














0












0








0







In C# you can save sensitive information in app.config file, like this:



  <appSettings>
<add key="ShopBaseUrl" value="http://automationpractice.com/index.php" />
</appSettings>


And then take this information, using this code:



System.Configuration.ConfigurationManager.AppSettings["ShopBaseUrl"]);


Which will return to you a value from app.config, which has key: ShopBaseUrl






share|improve this answer













In C# you can save sensitive information in app.config file, like this:



  <appSettings>
<add key="ShopBaseUrl" value="http://automationpractice.com/index.php" />
</appSettings>


And then take this information, using this code:



System.Configuration.ConfigurationManager.AppSettings["ShopBaseUrl"]);


Which will return to you a value from app.config, which has key: ShopBaseUrl







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 1 '18 at 14:05









UkrainisUkrainis

337110




337110













  • but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

    – Shiliang Fang
    Dec 21 '18 at 2:56











  • If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

    – Ukrainis
    Dec 21 '18 at 7:09



















  • but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

    – Shiliang Fang
    Dec 21 '18 at 2:56











  • If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

    – Ukrainis
    Dec 21 '18 at 7:09

















but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

– Shiliang Fang
Dec 21 '18 at 2:56





but the people who use my automation script in the VisualStudio also have access to App.Config, right? they still can see my password from the code.

– Shiliang Fang
Dec 21 '18 at 2:56













If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

– Ukrainis
Dec 21 '18 at 7:09





If they know, where to search, then they can find it. If no, then they will not find it. Then other solution would be storing passwords on external services, like KeyWault, and take then at the run time.

– Ukrainis
Dec 21 '18 at 7:09




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53491513%2fhow-to-hide-password-in-selenium-webdriver-c-sharp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Tonle Sap (See)

I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

Guatemaltekische Davis-Cup-Mannschaft