1

I have created a test that checks the following:
You open the browser on a remote windows client (either Firefox/Chrome or Edge using their webdriver and selenium server), the browser opens with a URL, either Facebook or Paypal or another phishing URL.
It goes to an element of my choosing (either the email/username/password) according to its xpath,clicks it, and checks if the site was blocked or allowed depending on my phishing signature.
Now, this test works but if I'd like to add more sites for tests later on, I'd have to either create new tests for each new site or change the xpath of the tests I have. It's not a very reliable method of testing (as xpaths can also change on a webpage).

I would like to have the same test in a more reusable format.
The test I would like to do is:

  • Open a webpage.
  • Scan for any forms or input type fields.
  • Click each element found one after the other and wait for a verdict for each of some kind (either a redirect to a block page or if the page remained open after clicking).

Are there any keywords in robot that know how to handle that?
Was wondering if the Robot Framework has something similar to what is already done.

1 Answer 1

5

You can try to parse webpage for all inputs using Selenium's Get WebElements with xpath like //input - this will return you a list of all elements and then you can check that element is not hidden and click/fill it. I'd suggest to use data-driven approach with Robot framework's Test Templates, like

*** Settings *** Library Selenium(or any other) Test Template Scan input elements test *** Keywords *** Scan input elements test [Arguments] ${url} ${selector} ${whatever} Open webpage ${url} ${inputs}= Get WebElements FOR ${element} IN @{inputs} Click Element ${element} # or do something else END Assert or wait for smth ${whatever} *** Test Cases *** Scan input elements test facebook.com //input blocked 

Also here Run Keyword And Return Status can be useful so your test will not fail if input will be not clickable etc. But such tests are really flaky as there are over 9000 ways to build an HTML form :)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks applekate! Is there any way of finding the login/firstname input fields in robot?
You can try to find input with name="login/firstname" using Run Keyword And Return Status instead of try/catch, or simply create a python script keyword

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.