0

I'm trying to make a bot that creates accounts for me, but I can't interact with the element where I need to send my credentials.

All I know is that the element that I'm trying to interact with is generated in javascript, after clicking on another button. I found multiple answers but all were in others languages than Node.js.

I'm trying to send credentials on this element:

<input type="text" name="pseudo" id="pseudo" placeholder="Mon pseudo légendaire" style="margin-bottom: 10px;" maxlength="10">

I tried to use this:

driver.findElement(By.xpath('//*[@id="pseudo"]')).sendKeys('CREDITENTIALS')

Which returns me this error: Webdrivererror: element is not visible.

HTML element code looks like this :

<input type="text" name="pseudo" id="pseudo" placeholder="Mon pseudo légendaire" style="margin-bottom: 10px;" maxlength="10">

The problem is not that i have to wait until the element that im trying to interact with is displayed because it is already displayed, the problem is that i want to click on the second element that match with my findElement by xpath, because what im trying to click on is existing 2 times in the html code and only the second one is interactible.


Update (from the comments)

This element is within the following <div> tag:

<div id="modal_message_wrapper" class="block_scrollable_wrapper scrollbar-light yellow noise inscription">
8
  • Do you have a waitForElementVisible command? Commented Jul 9, 2018 at 12:51
  • No, i don't have a waitForElementVisible command. Commented Jul 9, 2018 at 12:55
  • If you have other examples of selenium scripts they should just work. Selenium is language agnostic, the syntax might change slightly, uppercase lowercase letters on interfaces, etc. but the underlying principle should work Commented Jul 9, 2018 at 14:21
  • It sounds like your actual problem is this How to force Selenium WebDriver to click on element which is not currently visible? Commented Jul 9, 2018 at 14:22
  • That all said we need a Minimal, Complete, and Verifiable example of your problem or else we're just guessing Commented Jul 9, 2018 at 14:25

1 Answer 1

1

You can construct an unique xpath clubbing up the id, name and placeholder attribute as follows:

driver.findElement(By.xpath("//input[@id='pseudo' and @name='pseudo' and @placeholder='Mon pseudo légendaire']")).sendKeys('CREDITENTIALS')

Update

As you mentioned that the desired element is within:

<div id="modal_message_wrapper" class="block_scrollable_wrapper scrollbar-light yellow noise inscription">

So you can use the following line of code:

driver.findElement(By.xpath("//div[@class='block_scrollable_wrapper scrollbar-light yellow noise inscription' and @id='modal_message_wrapper']//input[@id='pseudo' and @name='pseudo' and @placeholder='Mon pseudo légendaire']")).sendKeys('CREDITENTIALS')

Note: It's quite evident the element is within a Modal Dialog Box, so definitely you have to induce a waiter in the form of WebDriverWait before you attempt to send any character sequence to the <input> element.

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

4 Comments

Yeah but the thing is that both of the elements are exactly the same :/
@Zayonx So it's quite evident we can't reach to a solution with the HTML you have provided. You have to provide us the HTML through which we can differentiate the 2 element and focus on the desired element.
There is one thing different between both of them : The one that i want to click on is inside this : <div id="modal_message_wrapper" class="block_scrollable_wrapper scrollbar-light yellow noise inscription">
@Zayonx Checkout my answer update and let me know the status

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.