在Moneycontrol的登录页面中,Selenium无法找到Webelementes

时间:2017-12-27 15:30:00

标签: selenium selenium-webdriver

在Moneycontrol的website中,我无法在尝试登录时输入用户名和密码.Selenium无法找到Webelements。

public void setUrl() throws IOException {
  driver = new FirefoxDriver()
  driver.get("http://www.moneycontrol.com/");
}

public void Login() {
    driver.findElement(By.xpath("//a[@title='Log In']")).click();
    //enter user name and password

    driver.findElement(By.xpath("//div[@class='formbox']/div[1]/form/div[1]")).sendKeys("xyz@gmail.com");
    driver.findElement(By.xpath("//input[@id='pwd']")).sendKeys("Abc@92");

screenshot

2 个答案:

答案 0 :(得分:0)

(define (split3 xs) (cond ((null? xs) (list '() '() '())) (else (apply (lambda (a b c) ; Scheme-style destructuring (list (cons (car xs) c) ; rotate right: a ; xs's 2nd elt to appear in the 2nd group! b)) ; head element of (cdr xs) is in `a` (split3 (cdr xs)))))) ; the recursive result (split3 '(a b c 1 2 3)) (split3 '(a b c 1 2)) ; '((a 1) (b 2) (c 3)) ; '((a 1) (b 2) (c)) 字段位于Email or User ID内,因此要在 <iframe> sendKeys() > Email or User ID 字段,您必须切换到相应的Password,如下所示:

<iframe>

答案 1 :(得分:0)

 **Selenium with C#**

您需要切换到框架,在您的情况下,框架的ID是&#34; myframe&#34;。下面是使用C#

的硒的工作代码
[TestMethod]
public void moneyControl()
{
    IWebDriver driver = new ChromeDriver(@"C:\Users\Akash\Downloads\chromedriver_win32\");
    driver.Navigate().GoToUrl("http://www.moneycontrol.com/");
    driver.Manage().Window.Maximize();
    driver.FindElement(By.XPath("//a[@title='Log In']")).Click();
    driver.SwitchTo().Frame("myframe");
    driver.FindElement(By.Id("email")).SendKeys("xyz@gmail.com");
    driver.FindElement(By.Id("pwd")).SendKeys("abc");

}