0

I am getting an error "Value cannot be null,parameter name: s" after setting password through selenium script and clicking submit button.

Please help me on this, Thanks

Am using the below code for setting password

var passwordtxt=driver.FindElement(By.Id("txtpassword"));
var JSexecutor= (IJavaScriptExecutor)driver;
JSexecutor.ExecuteScript("arguments[0].setAttribute('value', arguments[1])",passwordtxt,"mypassword");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Vineeth
  • 1
  • 1
  • Why not `Sendkeys()`? – undetected Selenium Sep 20 '19 at 10:58
  • You could use sendKeys(), can you share the HTML source? This might help: https://stackoverflow.com/questions/28176498/how-to-enter-password-using-selenium-webdriver-if-the-password-style-is-display – Atul Sep 20 '19 at 11:38
  • when I am using SendKeys, am getting an error " Element cannot be interacted with via the keyboard because it is not diplayed". But element is visible in the page. – Vineeth Sep 20 '19 at 11:58
  • then you are probably sending the value to the wrong element. If you can share the relevant section of HTML source, we could confirm that. – Breaks Software Sep 20 '19 at 13:17

1 Answers1

0

Based on the error message you provided, it sounds like the item passwordtxt doesn't exist on the page. Value cannot be null is referring to the element you pass into ExecuteScript, which is passwordtxt in this case.

To solve this problem, you will need to change the way you are finding passwordtxt. If you post some more HTML from your page's source, we can help you determine the correct selector to use.

CEH
  • 5,701
  • 2
  • 16
  • 40