Using Selenium in PowerShell, cannot capture dropdown

I have been attempting to automate a web page (help desk form) in PowerShell with the Selenium module. I can get all different types of elements except dropdowns. I have inconsistently been able to get some of them by doing a Find-SEElement and using the -xPath, performing a click() and then doing a Find-SEElement again on the resultant drop down list, but this does not
always work. The one I am working on at the moment looks like this:
$User = Find-SeElement -Driver $chrome -Timeout 30 -XPath "//span[@id='control-wrapper-mainForm-GroupBoxDesignerControl4']//tr[1]//td[2]"
I can confirm that I do find the element, but if I try to do anything except click on it I get the "element is not interactable" error. I was reading through some other forums, and someone suggested doing something like this:
$User = Find-SeElement -Driver $chrome -Timeout 30 -XPath "//span[@id='control-wrapper-mainForm-GroupBoxDesignerControl4']//tr[1]//td[2]" $Value = 'Joe Smith' $SelectElement = [OpenQA.Selenium.Support.UI.SelectElement]::new($User) $SelectElement.SelectByValue($Value)

When I run this, however, I get the error “Element should have been select but was td”. Googling this I have seen a number of threads and solutions for other languages such as Python and C#, but nothing specific to PowerShell. I am just looking for a consistent syntax to be able to grab a dropdown menu and select an item from the resultant list.

Edit: I did realize that the element is a /td, not a select, after posting, based on the XPath. The question remains, however, how to consistently grab the dropdown menu and then select a value. I have done it like this (different element name but shows same issue):

$taskLink = Find-SeElement -Driver $chrome -Timeout 30 -Wait -XPath “//li[contains(text(),‘Add Task’)]”
Invoke-SeClick -Element $taskLink -Driver $chrome
$taskDropdown = Find-SeElement -Driver $chrome -Timeout 60 -XPath “//div[@id=‘mainForm-_SupportGroup-Dropdown’]//div[4]”
[System.Windows.Forms.SendKeys]::SendWait(‘hosting’);

And it works, but not if I were to try and run this as a scheduled task due to the Windows SendKeys call

hey, did you ever get a response on how to automate selecting a dropdown menu on a webpage and also filling in text boxes? I’m trying to figure out how to automate those entries. Any tips would be helpful. Thank you in advance.

Carlos,
Welcome to the forum. :wave:t3:

Please do not hijack other peoples threads. If you have the same or a similar issue create a new question for yourself and place a link to the thread you wnat to refer to in your question.

I will close here now since the thread has been unanswered for 4 years now and the OP has been seen last more than 2 years ago.