Accept cookie pop up

Hello, i got this accept pop up and I am not able to to use the click element to accept and move on with the test case.

Any help please.

Hi! Is that a public website? If so, please provide a link. If not, can you paste the HTML markup?

Hi, yes it is a public site https://hub.knime.com/

Thanks! This works for me:

*** Settings ***
Library           RPA.Browser.Selenium

*** Tasks ***
Accept cookies
    Open Available Browser    https://hub.knime.com/
    Click Element When Visible    css=.accept-button

The example uses RPA.Browser.Selenium but the same should work with plain SeleniumLibrary using Wait Until Element Is Visible.

I am getting the below error:
No keyword with name ‘Click Element When Visible’ found.

The example uses a different library, see above. :slight_smile:

Then I have an other newbie question. I did search for that library in Pycharm but could not find it.

Hi! Tried to mention in the original that you can do the same with SeleniumLibrary. You probably missed that. :slight_smile:

  • Wait
  • Click
  • Profit!

That worked thanks a lot :slight_smile. How do you extract the CSS?

Short answer: browser inspector tools

This article explains the topic in more detail: How to find user interface elements using locators in web applications | Robocorp documentation

1 Like

That was very useful thanks again. I have now stuck again with the username and password fields :frowning:

How are you stuck? What have you tried?

I was able to clear that after few tries.
I need to handle an or situation. Like if the first one does not work try the other one type of stuff.

  1. seleniumlibrary.click element css:#__layout > div > div.sticky-footer > main > section > div > div.grid-item-9.child-container > div > div > ul > li:nth-child(10) > div > div > button:nth-child(1)
  2. seleniumlibrary.click element css:#__layout > div > div.sticky-footer > main > section > div > div.grid-item-9.child-container > di
    any thought?

Just as a side note - there’s probably a CSS class or a UI element text you can target. The current selector would break quite easily if the HTML structure changes even a bit. I warmly recommend finding a shorter way to point to whatever element you are pointing to.

Regarding the “or” question: You have a few options.

Run Keyword And Ignore Error    Click    some-selector
Run Keyword And Ignore Error    Click    another-selector

That will try and click both and ignore any errors. They don’t care if something fails. The end result should be that if either succeeds, you can then proceed with the script.

Another option is to check if the elements exist before clicking and only clicking if they do exist.

What is your use case here?

1 Like

I am using the css but the space keep moving as I had work flow so it work once and then failed because the element has moved.

Is that element behind the login? If not, I could give it a try.

Yes it is after login :frowning:

Well, I’m a member now! :smiley: Can you tell what you were trying to do and with what elements?

Thank you :slight_smile:
this keeps moving as I create new spaces so first time test pass but then after it does fail because it as moved.
image

I have no idea about this application. What are spaces and where do I create them? If you can point me there, then I might be able to help with the elements.