SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Using field mapping

    Hi guys,


    I am trying to login in a system but seems that it does not recognize the field I mapped.

    I am using the following script:

    package org.openqa.selenium.example;

    import org.openqa.selenium.By;
    import org.openqa.selenium.Proxy;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class Script_003 {

    public void runTest003 () {

    //Configurar Firefox para rodar sem proxy
    DesiredCapabilities cap = DesiredCapabilities.firefox();
    Proxy proxy = new Proxy();
    proxy.setNoProxy("http://homologacao.trt12.jus.br/");
    cap.setCapability(CapabilityType.PROXY, proxy);
    WebDriver driver = new FirefoxDriver(cap);

    // Preencher URL
    driver.get("https://homologacao.trt12.jus.br/proad");

    // Preencher usuário
    WebElement login = driver.findElement(By.name("username"));
    login.sendKeys("PROAD2");

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    }

    public static void main(String[] args) throws Exception {
    Script_003 script = new Script_003();
    script.runTest003();
    }
    }

    And I got the following error message in the Console:
    Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"name","selector":"username"}
    For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
    Build info: version: '2.5.0', revision: '13516', time: '2011-08-23 18:30:44'
    System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
    Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThro wable(ErrorHandler.java:131)
    at org.openqa.selenium.remote.ErrorHandler.throwIfRes ponseFailed(ErrorHandler.java:105)
    at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:409)
    at org.openqa.selenium.remote.RemoteWebDriver.findEle ment(RemoteWebDriver.java:197)
    at org.openqa.selenium.remote.RemoteWebDriver.findEle mentByName(RemoteWebDriver.java:246)
    at org.openqa.selenium.By$ByName.findElement(By.java: 298)
    at org.openqa.selenium.remote.RemoteWebDriver.findEle ment(RemoteWebDriver.java:189)
    at org.openqa.selenium.example.Script_003.runTest003( Script_003.java:27)
    at org.openqa.selenium.example.Script_003.main(Script _003.java:59)
    Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownSer verException: Unable to locate element: {"method":"name","selector":"username"}
    Build info: version: '2.5.0', revision: '13516', time: '2011-08-23 18:30:44'
    System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27'
    Driver info: driver.version: unknown
    at <anonymous class>.WebDriverError(file:///C:/DOCUME~1/LUIZGU~1/CONFIG~1/Temp/anonymous6127080354515709601webdriver-profile/extensions/fxdriver@googlecode.com/resource/modules/utils.js:8733)

    I identified the field name through the source code:

    <tr>
    <td style="text-align:left;"><label for="username"><span class="accesskey">M</span>atrícula:</label></td>
    <td style="text-align:left;"><input class="required" id="username" name="username" size="15" accesskey="n" /></td>
    </tr>


    Does anyone knows what it is?!


    Best regards,
    Luiz Gustavo Schroeder Vieira, FCE, CTAL-TA
    Test Consultant
    BSTQB TAG Member
    +55 (48) 9994-3569
    Skype: luizgsvieira
    luizgustavo@LUGATI.com
    http://testavo.blogspot.com
    http://www.LUGATI.com

  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Error on field mapping

    I already tried to use other ways to find the elements, like:
    driver.findElement(By.id("username"));

    whatever.

  3. #3
    Junior Member
    Join Date
    Jan 2011
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Error on field mapping

    Great catch! I used thinktime before driver.get("URL");

    Check this out:

    package org.openqa.selenium.example;

    import org.openqa.selenium.By;
    import org.openqa.selenium.Proxy;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class Script_003 {

    public void runTest003 () {

    //Configurar Firefox para rodar sem proxy
    DesiredCapabilities cap = DesiredCapabilities.firefox();
    Proxy proxy = new Proxy();
    proxy.setNoProxy("http://homologacao.trt12.jus.br/");
    cap.setCapability(CapabilityType.PROXY, proxy);
    WebDriver driver = new FirefoxDriver(cap);

    //Think time
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

    // Preencher URL
    driver.get("https://homologacao.trt12.jus.br/proad");

    // Preencher usuário
    WebElement login = driver.findElement(By.name("username"));
    login.sendKeys("PROAD2");

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    }

    public static void main(String[] args) throws Exception {
    Script_003 script = new Script_003();
    script.runTest003();
    }
    }

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.50%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:50 PM.

Copyright BetaSoft Inc.