1

I am writing a script to automatically fill out a form for me, but I am struggling to 'find element'. I can see it when I inspect, but I cant get it to send information to the placeholder.

This is the element im trying to send_keys to.

<input type="text" placeholder="Next step" class="pl-10 pr-12 form-input block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:shadow-outline-blue focus:border-blue-300 transition duration-150 ease-in-out sm:text-sm sm:leading-5" required="" value="">

This is the parent element.

<div class="nested-fields air-pipeline-step-item" draggable="true" data-handler-id="T0" style="opacity: 1;"><input name="vacancy[vacancy_pipeline_steps_attributes][0][id]" type="hidden" value=""><input name="vacancy[vacancy_pipeline_steps_attributes][0][step_order]" type="hidden" value="0"><input name="vacancy[vacancy_pipeline_steps_attributes][0][display_name]" type="hidden" value="Awaiting Review">

When trying:

self.driver.find_element_by_name('vacancy[vacancy_pipeline_steps_attributes][0][id]').click()

I get:

ElementNotVisibleException: Message: element not visible

I would like to click on this element and then give it a value. Any suggestions on how to do this ?

7
  • Can you share a link to that page? Commented Jul 12, 2021 at 11:44
  • Can you share any type of error you are getting? You should be able to fill out a text box using the elements name like: driver.find_element_by_name("ElementName").send_keys("TextToSend"). That uses element name to find the element, but you can use other methods. Commented Jul 12, 2021 at 11:45
  • I cannot unfortunately, but I can give me information around that element if that helps ? @Prophet Commented Jul 12, 2021 at 11:47
  • The problem is that Im not sure what to 'find_element_by'. There is no name, id, link_text to find_by. @JasonCook Commented Jul 12, 2021 at 11:50
  • Maybe giving parent elements will help. The element itself attributes doesn't look like unique values. Commented Jul 12, 2021 at 11:54

2 Answers 2

1

I would use a css selector here – allows for more versatile element selection:

css_selector = 'div[class*="nested-fields"][class*="air-pipeline-step-item"] > input[type="text"]'

# Easier to navigate try and excepts with find many
my_input = self.driver.find_elements_by_css_selector(css_selector)
if my_input:
    my_input = my_input[0]
else:
   # Try a diff selector – or raise an error
   raise ValueError(f'couldn\'t find an element with using {css_selector=}')

# Continue code here 
my_input.send_keys('Hello World!')
Sign up to request clarification or add additional context in comments.

1 Comment

Does this solve your problem? @andrew-reiblein
0

you can use find_element_by_class_name() method to find the element and the send the keys. So the code will look like this.

// driver should be initialized before
field = driver.find_element_by_class_name("class_name")
field.sendKeys("key")

Comments

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.