How to click a link under drop down menu

Welcome Forums General PowerShell Q&A How to click a link under drop down menu

This topic contains 4 replies, has 2 voices, and was last updated by

 
Participant
3 years, 3 months ago.

  • Author
    Posts
  • #29476

    Participant
    Points: 0
    Rank: Member

    Hi all,
    I am new to this community since I am only a beginner in PS.
    I am trying to automate data upload to a certain website. I was able to dial and log in so so far. However, there is one part that I am stuck. I am trying to click a link which is under a certain title. Here how that looks like:

    ul
    li
    "a title="" href="https://......?alerts=1" target="_self">Inventory AlertsInventory Management

  • #29479

    Participant
    Points: 316
    Helping Hand
    Rank: Contributor

    That is HTML, not Powershell. Are you creating a HTML Report from Powershell? Your question is vague and there is no Powershell code to look at. Please provide more information.

  • #29481

    Participant
    Points: 0
    Rank: Member

    Sorry about the confusing message. I was having trouble while I was posting.
    Here is my code
    # Initiate an internet explorer object
    $ie = New-Object -com InternetExplorer.Application
    $ie.Visible = $True
    $url = "https://partners.wayfair.com/v/login/index?going_to=%2Forder_management.php"
    $ie.navigate($url)
    while($ie.busy){Start-Sleep 1}

    # Enter login information
    $ie.Document.getElementById("js-username").value = "username"
    $ie.Document.getElementById("password_field").value = "password"
    $ie.Document.getElementById("submit_button").Click()

    # Click Inventory Management under Inventory & EDI Tab or Dropdown menu
    I am trying to click a drop down menu under Inventory & EDI tab.
    When I inspect the elements this what I get
    ul id="Inventory_&_EDI"

    li id="js-inventory-alerts-link"
    a title = "" href = "https://.....................................php?alerts=1" target="_self">Inventory Alerts
    /li
    li
    a title="" href = "https://.......................................php" target="_self">Inventory management

  • #29546

    Participant
    Points: 316
    Helping Hand
    Rank: Contributor

    Although you are using Powershell to run this code, you are actually using HTML Document Object Model (DOM). Most DOM examples will be JavaScript that will provide examples of how to access dropdown children and perform actions. You may also see jQuery, but keep in mind that it is basically JavaScript short-hand and will be difficult to translate into something usable with a DOM approach unless you understand jQuery. I searched for "javascript open link in dropdown" and there are examples of opening a link in another window. You would use Navigate or Navigate2 versus Window.Open.

  • #29576

    Participant
    Points: 0
    Rank: Member

    Thank you, Rob.
    I have handled this part of the program with PowerShell.
    There are many challenges waiting ahead though.

The topic ‘How to click a link under drop down menu’ is closed to new replies.