1

I am studying Robot Framework with Selenium Library and I can't figure out how to remove "kw" element from the next dropdown:

enter image description here

I tried to use xpath for it:

*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
MyTest
 Create Webdriver Chrome executable_path=chromedriver.exe
 Open Browser http://127.0.0.1:85/ Chrome
 Sleep 10
 Click Link xpath=//body/div[@id='react-entry-point']/div[@id='_dash-global-error-container']/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/span[1]

But it doesn't work. I am getting:

Link with locator 'xpath=//body/div[@id='react-entry-point']/div[@id='_dash-global-error-container']/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/span[1]' not found.

If I try //span[text()='kw'] or //span[contains(.,'kw')] or //div[@class='Select-value']//span[contains(.,'kw')] I would get the same error.

Also I tried to access to this element via List by Value instead of Click Link:

 Unselect From List by Value xpath=//body/div[@id='react-entry-point']/div[@id='_dash-global-error-container']/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/span[1]

But I am getting an error:

List with locator 'xpath=//body/div[@id='react-entry-point']/div[@id='_dash-global-error-container']/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/span[1]' not found.

Here is HTML code for dropdown menu:

 <div style="display: inline-block; height: 20px; width: 300px; margin-left: 25px;" xpath="1"><div id="Type_id" class="dash-dropdown"><div class="Select has-value is-clearable is-searchable Select--multi"><div class="Select-control"><div class="Select-multi-value-wrapper" id="react-select-2--value"><div class="Select-value"><span class="Select-value-icon" aria-hidden="true"&g×ばつ</span><span class="Select-value-label" role="option" aria-selected="true" id="react-select-2--value-0">kw<span class="Select-aria-only">&nbsp;</span></span></div><div class="Select-value"><span class="Select-value-icon" aria-hidden="true"&g×ばつ</span><span class="Select-value-label" role="option" aria-selected="true" id="react-select-2--value-1">teardown<span class="Select-aria-only">&nbsp;</span></span></div><div class="Select-value"><span class="Select-value-icon" aria-hidden="true"&g×ばつ</span><span class="Select-value-label" role="option" aria-selected="true" id="react-select-2--value-2">setup<span class="Select-aria-only">&nbsp;</span></span></div><div class="Select-input" style="display: inline-block;"><input id="Type_id" aria-activedescendant="react-select-2--value" aria-expanded="false" aria-haspopup="false" aria-owns="" role="combobox" value="" style="box-sizing: content-box; width: 5px;"><div style="position: absolute; top: 0px; left: 0px; visibility: hidden; height: 0px; overflow: scroll; white-space: pre; font-size: 15px; font-family: &quot;Open Sans&quot;, HelveticaNeue, &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-weight: 400; font-style: normal; letter-spacing: normal; text-transform: none;"></div></div></div><span aria-label="Clear all" class="Select-clear-zone" title="Clear all"><span class="Select-clear"&g×ばつ</span></span><span class="Select-arrow-zone"><span class="Select-arrow"></span></span></div></div></div></div>

Here is a link to full HTML code: https://jsfiddle.net/illuminato/u24j6wbh/

asked Oct 8, 2020 at 15:18
2
  • 1
    This xpath=//body/div[@id='react-entry-point']/div[@id='_dash-global-error-container']/div[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/span[1] is quite error-prone. Could you simplify it? Commented Oct 8, 2020 at 16:15
  • @pavelsaman Sorry, but I don't know how it could be done.I just copy this xpath via "inspect element" in browser Commented Oct 8, 2020 at 18:46

1 Answer 1

1

Use the below keyword and locator:

Click Element //span[text()='kw']/../*[@class="Select-value-icon"]

Click Link match is based on "on link text and href." as span is not a link it may not work

answered Oct 9, 2020 at 8:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.