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.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:131)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:105)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:409)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:197)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:246)
at org.openqa.selenium.By$ByName.findElement(By.java:298)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(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$UnknownServerException: 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/fxdr...@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.brhttp://testavo.blogspot.comhttp://www.
LUGATI.
com.br