0

Updated outer html and latest error. It seems the element was detected but failed to click onto it.

My script fail at below element, I have tried many way to re-construct xpath but the robot keep failing the DOM invalid.

original element:

<div class="ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search">
<div class="ant-select-selector">
    <div class="ant-select-selection-overflow">
        <div class="ant-select-selection-overflow-item ant-select-selection-overflow-item-suffix" style="opacity: 1;">
            <div class="ant-select-selection-search" style="width: 3px;">
                <input autocomplete="off" type="search" class="ant-select-selection-search-input" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_2_list" aria-autocomplete="list" aria-controls="rc_select_2_list" aria-activedescendant="rc_select_2_list_0" value="" id="rc_select_2" style="opacity: 0;" aria-expanded="false" readonly="" unselectable="on">
                    <span class="ant-select-selection-search-mirror" aria-hidden="true">&nbsp;</span>
                </div>
            </div>
        </div>
        <span class="ant-select-selection-placeholder">Select Source(s)</span>
    </div>
</div>

script:

*** Settings ***
Library    Browser
Library    OperatingSystem
Resource   ../Resources/BrowserParameters.robot
Resource   ../Resources/BrowserResources.robot
Resource   ../Resources/BrowserCustomKeywords.robot

#Select Browser: chromium or firefox
Test Setup      Test Setup    Browser=chromium
Test Teardown   Test Teardown

*** Test Cases ***
001
   Click     //span[contains(@class,'ant-select-selection-placeholder') and contains(text(),'Select Source(s)')]

Error

    FAIL
Message:    TimeoutError: locator.click: Timeout 10000ms exceeded.
=========================== logs ===========================
waiting for selector "//span[contains(@class,'ant-select-selection-placeholder') and contains(text(),'Select Source(s)')] >> nth=0"
  selector resolved to hidden <span class="ant-select-selection-placeholder">Select Source(s)</span>
attempting click action
  waiting for element to be visible, enabled and stable
    element is not stable - waiting...
  element is visible, enabled and stable
  scrolling into view if needed
  done scrolling
  checking that element receives pointer events at (1080.4,304.7)
  <div class="ant-select-selection-overflow">…</div> intercepts pointer events
retrying click action, attempt #1
  waiting for element to be visible, enabled and stable
  element is visible, enabled and stable
  scrolling into view if needed
  done scrolling
  checking that element receives pointer events at (1080.4,304.7)
    [ Message content over the limit has been removed. ]
  element is visible, enabled and stable
  scrolling into view if needed
  done scrolling
  checking that element receives pointer events at (1080.4,304.7)
  <div class="ant-select-selection-overflow">…</div> intercepts pointer events

If I use this, then I can see the field being accessed and list is displayed. however in the form has 2 fields using this same xpath. So robot accessed into 1st field, but I wanted it goes to next field.

Click     //div[@class="ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search"]
user2201789
  • 1,083
  • 2
  • 20
  • 45

3 Answers3

0

Please correct your Xpath from

//span[@class=""ant-select-selection-placeholder">Select Source(s)"]

to

//span[@class="ant-select-selection-placeholder"]

Or

//span[@class="ant-select-selection-placeholder" and (text()="Select Source(s)")]
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • I need to have this to make it unique. "Select Source(s)" – user2201789 Nov 10 '21 at 11:01
  • `"Select Source(s)"` is text, no a class name. I will update the answer – Prophet Nov 10 '21 at 11:06
  • updated main post with new error. i checked xpath is highlighted, but still the cursor seems not pointing into it. in manual way, when I click into the field, a list of values will be listed. – user2201789 Nov 11 '21 at 01:00
0

Please use below xpath

//span[contains(@class,'ant-select-selection-placeholder') and contains(text(),'Select Source(s)')]

or

//span[contains(@class,'ant-select-selection-placeholder') and starts-with(text(),'Select Source')]

Please check in the dev tools (Google chrome) if we have unique entry in HTML DOM or not.

Steps to check:

Press F12 in Chrome -> go to element section -> do a CTRL + F -> then paste the xpath and see, if your desired element is getting highlighted with 1/1 matching node.

If we have 1/1 matching node, Please make sure that :

  1. This div is not under an iframe.
  2. This div is not under a shadow-root.
  3. You should not be on new tab/windows launched by selenium.
cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • updated main post with new error. i checked xpath is highlighted, but still the cursor seems not pointing into it. in manual way, when I click into the field, a list of values will be listed. – user2201789 Nov 11 '21 at 01:00
0

This error message...

Error: locator.click: DOMException: Failed to execute 'evaluate' on 'Document': The string './/span[@class=""ant-select-selection-placeholder">Select Source(s)"]' is not a valid XPath expression.

...implies that the XPath you have used isn't a valid expression.

You have to make two minor adjustments as follows:

  • The value of the class attribute must be within single double quotes i.e. "value"
  • Select Source(s) is the innerText within, so you have to mention it as text.

Solution

You can use either of the following Locator Strategies:

  • xpath 1:

    //span[@class='ant-select-selection-placeholder' and starts-with(., 'Select Source')]
    
  • xpath 2:

    //span[@class='ant-select-selection-placeholder' and contains(., 'Select Source')]
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • updated main post with new error. i checked xpath is highlighted, but still the cursor seems not pointing into it. in manual way, when I click into the field, a list of values will be listed. – user2201789 Nov 11 '21 at 01:00