SA.
SA.

Reputation: 752

Selenium with powershell

I am trying to use Selenium with PowerShell. I have to capture a search button, but i am not able to do so. The element needs to be captured is

<a id="btnAdvSearchMenu" class="searchbox-btn" href="/AdvancedSearch.aspx" style="display: none;"></a>

I have the html as: enter image description here

When i hover the search option, it takes me to "btnAdvSearchMenu" tag.

I am using below PowerShell code to capture this. Please suggest if i am missing something.

$ChromeDriver.FindElementByClassName("searchbox-btn").click()

Upvotes: 0

Views: 294

Answers (1)

Prophet
Prophet

Reputation: 33361

You are trying to click invisible element. In the element XML you shared you can see style="display: none;".
Selenium imitates real user GUI actions. As a user you normally can't click invisible elements.
Also, there may be more problems with you code that we can't see since you shared only this information.
UPD
The updated XML shows that the element you trying to access is inside the iframe. In order to access elements inside iframe you need to switch driver to that iframe. Also, when finished and you will want to access elements out of that iframe block you will need to switch to the default content.
I know how to do that with normal languages like Python and Java but not a Powershell, I'm sorry. But I'm sure you can find examples for that here in Stackoverflow.

Upvotes: 2

Related Questions