0

I have problem with finding element on login page. I need to test login procedure. Web page where I have problem is part of SAP Business Object platform so it's not world wide. There is strange naming convention and I cannot send keys to user and password input element. It looks like this:

<div class="logonRow" id="_id0:logon:USERNAME:row">
<div class="logonLabel">
<label for="_id0:logon:USERNAME">Nazwa użytkownika:</label>
</div>
<div class="logonInput">
<input type="text" id="_id0:logon:USERNAME" name="_id0:logon:USERNAME" value="">
</div>

I'm using below java code. I tested it on other pages and it's working fine.

WebElement loginName = wd.findElement(By.name("_id0:logon:USERNAME"));
loginName.clear();
loginName.sendKeys(userName);

I will much appreciate advises.

PS.

I tried this with no luck:

WebElement loginName = wd.findElement(By.id("_id0:logon:USERNAME"));
WebElement loginName = wd.findElement(By.xpath("//*[@id='_id0:logon:USERNAME']"));
WebElement loginName = wd.findElement(By.cssSelector("label[for='_id0:logon:USERNAME']"));
WebElement loginName = wd.findElement(By.xpath("//label[@for='_id0:logon:USERNAME']"));

Here is error I receive:

org.openqa.selenium.NoSuchElementException: Unable to locate element: label[for='_id0:logon:USERNAME']
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'ROBERTTEST', ip: '10.5.241.54', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 63.0.3, javascriptEnabled: true, moz:accessibilityChecks: false, moz:geckodriverVersion: 0.23.0, moz:headless: false, moz:processID: 2792, moz:profile: C:\Users\mardudek\AppData\L..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 85cf59e4-eb21-4ec5-a2b3-afd0a0e6f956

Here is web page I saved: https://ufile.io/dqvbh

0

3 Answers 3

1

There was iframe in the page. First I to switched to iframe and then I found my element.

Sign up to request clarification or add additional context in comments.

Comments

0

maybe you should try to get the element by ID.

Try one of these:

WebElement loginName = wd.findElement(By.ID("_id0:logon:USERNAME"));
WebElement loginName = wd.findElement(By.xpath("//*[@id='_id0:logon:USERNAME']"));

1 Comment

Hi, I tried this with no luck. Any other ideas? I added page source.
0

As per the HTML you have shared to send a character sequence to the USERNAME field you can use either of the following solutions:

  • cssSelector:

    WebElement loginName = wd.findElement(By.cssSelector("label[for='_id0:logon:USERNAME']"));
    loginName.clear();
    loginName.sendKeys(userName);
    
  • xpath:

    WebElement loginName = wd.findElement(By.xpath("//label[@for='_id0:logon:USERNAME']"));
    loginName.clear();
    loginName.sendKeys(userName);
    

4 Comments

Hi, I tried this with no luck. Any other ideas? I added page source.
@dudemar Your comment doesn't helps me either. Sorry, the answer didn't help you to solve your problem but how am I going to improve my post with that feedback?
I hoped you would look into page source provided by me (ufile.io/dqvbh). But nevermind I solved this issue.
Well, you never updated me that you have updated the question with the page source. Anyways, good luck.

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.