Home > OS >  How can I handle a dropdown, which is not a select dropdown with robotframework selenium? (Filter bu
How can I handle a dropdown, which is not a select dropdown with robotframework selenium? (Filter bu

Time:12-04

I am trying to filter my search on eBay. I can not neither with Select from dropdow nor click on the "Condition" button to see the choices. I am trying to select only the new ones in my search. I have also tried executing JavaScript and i did not any exception, however it did NOT click. Based on the locator i have got element not found or element not interactable errors. I have also tried to wait for a certain time. My code is below. Thanks in advance!!!

*** Settings ***
Documentation  Basic Search Functionality
Library  SeleniumLibrary

*** Variables ***

*** Test Cases ***
Verify basic search functionality for eBay
    [Documentation]  This test case verifies the basic search
    [Tags]  Functional

    Start Testcase
    Verify Search Results
    Filter Results by Condition
    Finish Testcase

*** Keywords ***

Start Testcase
    Open Browser  https://www.ebay.de  chrome
    Maximize Browser Window
    Sleep    2s
    Click Button  id:gdpr-banner-accept

Verify Search Results
    Input Text    xpath://*[@id="gh-ac"]    mobile
    Press Keys  //*[@id="gh-btn"]  [Return]
    Page Should Contain    Ergebnisse für mobile

Filter Results by Condition
    Click Element    //*[@id="nid-h0w-16"]/button/span/span
    Click Element    //*[@id="nid-khs-17"]/div[2]/span[2]

#    Execute Javascript  $("#nid-h0w-16 > button").click()
#    Execute Javascript  $("#nid-h0w-15 > div:nth-child(2) > span.filter-menu-button__text").click()
#    Sleep    5s

Finish Testcase
    Close Browser

CodePudding user response:

This is because the id you're using to access the element is a dynamic id. Everytime you refresh the page it will be different.

You'll need another way to locate the element thats not dynamic. You could try using a class or an xpath that searches for text within the button. Something like this to give you an idea:

Click Element    xpath=//button/span/span[contains(text(), 'Beste Ergebnisse')]
  • Related