0

I'm a beginner at using python3 and selenium, and I'm trying to click specific value in dropdown options.

I tried using select and actionchains, execute_script with js, xpath, css... etc. but it can't find the element despite the website being fully loaded. I also tried clicking the dropdown for using coordinate, and pressing arrow keys in keychain, but that also hasn't worked.

So I checked the all html, and found that the type of dropdown is hidden.

Is there any way to disable the hidden type or clicking value that I want?

The html code is below:

<input type="hidden" name="txtPosiCd" value="">
<select onchange="" name="txtPosiCd" style="width:150px;" class="textfield" title="직급">

                                
<option value="">전체</option>
                            <option value="11">교수</option>
<option value="12">부교수</option>
<option value="13">조교수</option>
<option value="15">강사</option>
<option value="21">명예교수</option>
</select>

I'm sorry for only attaching the html block; the webpage is only available to its members.

I've tried Googling and searching for solutions, but I couldn't understand the explanations or they were methods I already tried and failed. If there is anything I might have missed, please let me know.

2 Answers 2

0

See, Selenium Doesn't allow us to directly interact with the hidden elements and that's it. In that case, if you try to interact; you'll see "ElementNotInteractable" Exception.

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

Comments

0

In selenium, you can find the hidden elements but can't operate them with click(), clear(), send_keys() or other methods.

ele = driver.find_element_by_id("example")
print(ele)
ele.send_keys("example") # This will raise ElementNotVisibleException error

However, you can try to operate them with the js code. Assuming you are going to click this hidden link:

<a hidden id="google" href="https://google.com">

You can perform the click operation with the following code.

js = 'document.getElementById("google").click()'
driver.execute_script(js)

And, as per your situation, you can try the following code:

# make the input element show up
js = document.getElementsByName('txtPosiCd')[0].type = ''
driver.execute_script(js)

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.