0

I am trying to login to "https://www.quora.com/" , It has login screen where I put my username and password , It always throws Element not visible, I have gone through all other answers on SO , none of them working.

I tried to click the element via Javascript and ScrollintoView , but no avail.

IWebElement uname = driver.FindElement(By.Name("email"));

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", uname);
js.ExecuteScript("arguments[0].scrollIntoView()", uname);
js.ExecuteScript("arguments[0].click()", uname);
uname.SendKeys("[email protected]");

None of them working.

3 Answers 3

1

There is one more login form (hidden) on page with <input name="email"> element. You need to handle visible one. Try to use below code to locate required input field:

IWebElement uname = driver.FindElement(By.Xpath("//div[@class='login']//input[@name='email']"));
Sign up to request clarification or add additional context in comments.

4 Comments

I will check it , Once I get on to the system. thank you for your response.
It worked. I am learning to create xPath on my own. Want to suggest any resource?
You can also use a CSS selector here since XPath is not required. I find them easier to create/read, div.login input[name='email']. As for XPath resources, just about anything on MDN is good, e.g. developer.mozilla.org/en-US/docs/Web/XPath. XPath is a complicated and powerful language but you'll find that you don't need a lot of what is available when you just use it in Selenium. Make yourself a cheatsheet as you learn common locators and you'll get the basics down pretty quickly.
@PankajKushwaha , this one is quite useful
0

To login to https://www.quora.com/ you need to send a character sequence to the Email and Password field and you can use the following solution:

  • Email field:

    driver.FindElement(By.CssSelector("input.text.header_login_text_box.ignore_interaction[name='email']")).SendKeys("[email protected]");
    
  • Password field:

    driver.FindElement(By.CssSelector("input.text.header_login_text_box.ignore_interaction[name='password']")).SendKeys("PankajKushwaha");
    

Comments

0

Find C# code for login as follows

[TestMethod]
    public void QuoraLogin()
    {
        ChromeDriver webDriver = new ChromeDriver();
        WebDriverWait wait = new WebDriverWait(webDriver, new TimeSpan(0, 0, 0, 30));
        webDriver.Navigate().GoToUrl("https://www.quora.com/");
        IWebElement email= wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='login']//input[@name='email']")));
        email.SendKeys("[email protected]");
        IWebElement password = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='login']//input[@name='password']")));
        password.SendKeys("123");
        webDriver.FindElement(By.XPath("//div[@class='login']//input[@value='Login']")).Click();
    }

1 Comment

I did not want the code. I wanted the reason why it is behaving so. I appreciate your efforts although.

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.