0

What should happen is that these textfields for login should be filled and the the login button should be pressed (some sort of auto login)

Here is the link to the webpage: Telekom Email Login Page

This are the three methods I'm using:

public String exportDriver() throws IOException {
        final InputStream IEDriverStream = getClass().getResourceAsStream("/Driver/IEDriverServer.exe");
        final File ieDriverServer = FileWebOpener.stream2file(IEDriverStream, "IEDriverServer", ".exe");
        System.setProperty("webdriver.ie.driver", ieDriverServer.getAbsolutePath());
        return ieDriverServer.getAbsolutePath();
    }

    public void goToWebsite(String url) {
        driver = new InternetExplorerDriver();
        driver.get(url);
    }

    public void setUsernameAndPassword(String username, String password, int Website) throws InterruptedException {
       try{ new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#user[name='pw_usr']"))).sendKeys(username);
        driver.findElement(By.cssSelector("input#pw_pwd[name='pw_pwd']")).sendKeys(password);
        driver.findElement(By.cssSelector("input.button.standard_button_size.large#pw_submit")).click();
    } catch(Exception e){
           e.printStackTrace();
       }
    }

This is the exception I get

Community
  • 1
  • 1
Willey3x37
  • 310
  • 2
  • 12

5 Answers5

1

I believe you first need to :

  1. click on the username field.
  2. send username keys.
  3. click on the password field.
  4. send password keys.
  5. click on the submit button

try- findElement(By.Class("line_normalized clear relative").click);

this find the username textfield class and clicks on it if Im not mistaken, syntax may be wrong but the idea is the same. same goes for the password field, find the class/id name of the field & click on it before sending keys.

Roman Sterlin
  • 1,485
  • 3
  • 10
  • 25
  • I tried it like that: `WebElement line_normalized_clear_relative = driver.findElement(By.class("line_normalized clear relative")); line_normalized_clear_relative.findElement(By.id("user")).sendKeys(username);` I got this error message: _Unable to find element with css selector == .line_normalized\ clear\ relative For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html_ – Willey3x37 Mar 31 '19 at 13:23
  • If I understand correctly you are trying to input the login info into the fields and click on login, if so: WebElement line_normalized_clear_relative = driver.findElement(By.class("line_normalized clear relative").click()); to find the username field & click on it , then line_normalized_clear_relative.sendKeys ("the username"); then repeat with password & eventually click on submit – Roman Sterlin Mar 31 '19 at 13:27
  • Now I tried like you said: `WebElement line_normalized_clear_relative = driver.findElement(By.className("line_normalized clear relative")); line_normalized_clear_relative.click(); line_normalized_clear_relative.sendKeys(username);` Got the same error message as before I didn't get the element (textfield) and so everything else fails too. – Willey3x37 Mar 31 '19 at 13:39
0

Hi as you want to enter the username and it's a input field, you need to locate the input tag.

you can try the following locator to locate the text input area and perform the sendkeys operation:

driver.findElement(By.xpath("//div[@class='line_normalized clear relative']/input")).sendKeys("username");
Suraj Jogdand
  • 308
  • 2
  • 17
  • Did you mean something like that (to autofill username field): `driver.findElement(By.xpath("//div[@class='line_normalized clear relative']/input")).sendKeys(username);` – Willey3x37 Mar 31 '19 at 15:29
  • yeah, you just need to use the locator which i mentioned above, to locate the username text field, and then you can perform the sendkeys operation, it's working for me. – Suraj Jogdand Mar 31 '19 at 15:35
  • And the input is the tag of the textfield? – Willey3x37 Mar 31 '19 at 16:23
  • exactly! you just use the locator i have mentioned and it should solve your problem. – Suraj Jogdand Mar 31 '19 at 17:14
0

I suspect your application is too slow.Use WebDriverWait to identify the element and then Sendkeys operation.

package pkg1;

import java.io.File;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class testIE {

    public static void main(String[] args) {

        System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + File.separator + "\\Executables\\IEDriverServer.exe");
        WebDriver driver = new InternetExplorerDriver();        
        driver.get("https://accounts.login.idm.telekom.com/idmip?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Fverify%3FreturnToUrl%3Dhttps%3A%2F%2Femail.t-online.de%2Fem&openid.realm=https%3A%2F%2Ftipi.api.t-online.de&openid.assoc_handle=S4d53c348-b3f2-49a9-b13e-65ade0af6da4&openid.mode=checkid_setup&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_request&openid.ext1.type.attr1=urn%3Atelekom.com%3Aall&openid.ext1.required=attr1&openid.ns.ext2=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Foauth2%2F1.0&openid.ext2.client_id=10LIVESAM30000004901PORTAL00000000000000&openid.ext2.scopes=W3sic2NvcGUiOiJzcGljYSJ9XQ%3D%3D&openid.ns.ext3=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Fext%2F2.0&openid.ext3.logout_endpoint=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Flogout&openid.ns.ext4=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fui%2F1.0&openid.ext4.mode=popup");
        WebDriverWait wait = new WebDriverWait(driver, 30);
        WebElement user= wait.until(ExpectedConditions.elementToBeClickable(By.id("user")));
        user.sendKeys("user12345@gmail.com");
        WebDriverWait wait1 = new WebDriverWait(driver, 30);
        WebElement pass= wait1.until(ExpectedConditions.elementToBeClickable(By.id("pw_pwd")));
        pass.sendKeys("password");


    }

}

Output enter image description here

KunduK
  • 32,888
  • 5
  • 17
  • 41
0

As you are accessing the website initially you need to induce WebDriverWait for the desired elements to be clickable and you can use either of the following Locator Strategies:

  • cssSelector:

    driver.get("https://accounts.login.idm.telekom.com/idmip?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Fverify%3FreturnToUrl%3Dhttps%3A%2F%2Femail.t-online.de%2Fem&openid.realm=https%3A%2F%2Ftipi.api.t-online.de&openid.assoc_handle=S4d53c348-b3f2-49a9-b13e-65ade0af6da4&openid.mode=checkid_setup&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_request&openid.ext1.type.attr1=urn%3Atelekom.com%3Aall&openid.ext1.required=attr1&openid.ns.ext2=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Foauth2%2F1.0&openid.ext2.client_id=10LIVESAM30000004901PORTAL00000000000000&openid.ext2.scopes=W3sic2NvcGUiOiJzcGljYSJ9XQ%3D%3D&openid.ns.ext3=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Fext%2F2.0&openid.ext3.logout_endpoint=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Flogout&openid.ns.ext4=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fui%2F1.0&openid.ext4.mode=popup");
    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#user[name='pw_usr']"))).sendKeys("Jannik");
    driver.findElement(By.cssSelector("input#pw_pwd[name='pw_pwd']")).sendKeys("Jannik");
    driver.findElement(By.cssSelector("input.button.standard_button_size.large#pw_submit")).click();
    
  • xpath:

    driver.get("https://accounts.login.idm.telekom.com/idmip?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Fverify%3FreturnToUrl%3Dhttps%3A%2F%2Femail.t-online.de%2Fem&openid.realm=https%3A%2F%2Ftipi.api.t-online.de&openid.assoc_handle=S4d53c348-b3f2-49a9-b13e-65ade0af6da4&openid.mode=checkid_setup&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_request&openid.ext1.type.attr1=urn%3Atelekom.com%3Aall&openid.ext1.required=attr1&openid.ns.ext2=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Foauth2%2F1.0&openid.ext2.client_id=10LIVESAM30000004901PORTAL00000000000000&openid.ext2.scopes=W3sic2NvcGUiOiJzcGljYSJ9XQ%3D%3D&openid.ns.ext3=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Fext%2F2.0&openid.ext3.logout_endpoint=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Flogout&openid.ns.ext4=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fui%2F1.0&openid.ext4.mode=popup");
    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='user' and @name='pw_usr']"))).sendKeys("Jannik");
    driver.findElement(By.xpath("//input[@id='pw_pwd' and @name='pw_pwd']")).sendKeys("Jannik");
    driver.findElement(By.xpath("//input[@class='button standard_button_size large' and @id='pw_submit']")).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I tried the cssSelector method and get this error: `Element info: {Using=css selector, value=input#user[name='pw_usr']} at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)` – Willey3x37 Mar 31 '19 at 20:17
  • Can you please update the main question with your current code trial and the error stack trace? – undetected Selenium Mar 31 '19 at 20:19
  • Your code looks good enough **but** as you are using **java.version: '1.8.0_201'** can you upgrade to recent GA version of _Selenium_ ... Possibly _Selenium v3.141.59_ please? – undetected Selenium Mar 31 '19 at 20:33
  • Ok I will do this – Willey3x37 Mar 31 '19 at 20:35
  • Have done and now I get a new Exception what I have replaced in the previous link – Willey3x37 Mar 31 '19 at 21:08
  • Though you are using _Selenium_ of `version: '3.141.59'` the _InternetExplorerDriver server (64-bit)_ version is still `3.14.0.0`. Can you take the _IEDriverServer_ **v3.141.59** please? – undetected Selenium Mar 31 '19 at 21:13
  • I can't find the old versions of them. – Willey3x37 Mar 31 '19 at 21:57
  • I tried the path variation and now I get an error because the code waits that the element is clickable but it isn't and I guess there is a time period and after that it (selenium WebDriver) abort the process – Willey3x37 Apr 01 '19 at 12:45
0

I have tested it with C# and get the right behaviors. Below is the code:

using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using System;

namespace IEWebDriver
{
    class Program
    {
        static void Main(string[] args)
        {
            string username = args.Length > 1 ? args[1] : "test";
            string password = args.Length > 1 ? args[2] : "test";
            IWebDriver driver = new InternetExplorerDriver();
            //IWebDriver driver = new ChromeDriver();

            //Navigate to test URL
            driver.Navigate().GoToUrl("https://accounts.login.idm.telekom.com/idmip?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Fverify%3FreturnToUrl%3Dhttps%3A%2F%2Femail.t-online.de%2Fem&openid.realm=https%3A%2F%2Ftipi.api.t-online.de&openid.assoc_handle=S4d53c348-b3f2-49a9-b13e-65ade0af6da4&openid.mode=checkid_setup&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_request&openid.ext1.type.attr1=urn%3Atelekom.com%3Aall&openid.ext1.required=attr1&openid.ns.ext2=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Foauth2%2F1.0&openid.ext2.client_id=10LIVESAM30000004901PORTAL00000000000000&openid.ext2.scopes=W3sic2NvcGUiOiJzcGljYSJ9XQ%3D%3D&openid.ns.ext3=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Fext%2F2.0&openid.ext3.logout_endpoint=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Flogout&openid.ns.ext4=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fui%2F1.0&openid.ext4.mode=popup");

            try
            {
                new WebDriverWait(driver, new TimeSpan(0, 0, 20, 60)).Until(c => c.FindElement(By.CssSelector("input#user[name='pw_usr']"))).SendKeys(username);
                driver.FindElement(By.CssSelector("input#pw_pwd[name='pw_pwd']")).SendKeys(password);
                driver.FindElement(By.CssSelector("input.button.standard_button_size.large#pw_submit")).Click();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
            //Close the browser
            driver.Quit();
            //driver.Close();

        }
    }
}