Fitnesse test suite with variables - testing

Is it possible to set up a variable within the test suite so that it can be passed down to the setup fit page as a parameter value?

Sure. Use a !define xxx {yyy} on the suite page and a ${xxx} on the SetUp page. Make sure the SetUp page and all the test pages are children of the Suite page.

Have a look at the FlowFixture, this contains the keyword name.
More info at: http://www.syterra.com/FitnesseDotNet/NameKeyword.html

Related

Cucumber after each test I need to run a specific scenario, same as Background. Background is for before each, do we have similar for after each

Groups page functionality
Background:
Given When the user logs in
Then add the test group
#smoke
Scenario: Verify the groups list page
When the user opens the groups page
Then the group's page title should be visible
Cucumber does not have an after hook like background, but there is a workaround: if you want to run a after hook for a specific feature file then add a tag to the feature file, and then use that tag to write an after hook in the env file.
The given example is for capyabra with ruby
Test.feature
#test_tag
Feature: test feature file
env.rb file
After('#test_tag') do
# code for after hook
end
If you want to run an after hook for a specific scenario, use the same method. Add a tag for the scenario and pass it in after hook.
After('scenario1') do
# code
end
If you want a general after hook to run after every scenario, then we can directly write the After hook without tag
Example:
After do
# code
end
Note: The scenario parameter passed gives information for the scenario e.g scenario.failed? to check if the scenario ran successfully if you want to run logic not associated with scenario details in the After hook you can omit the parameter
Example:
After do|scenario|
if scenario.failed?
page.save_screenshot("path_#{scenario.name.parameterize}.png")
end
end

How to scan a page for input type element and click all of them, one by one?

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.
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 :)

Is the Selenium IDE test case property "Title" accessible to my script?

For example, if I create a new test case in the IDE, and it appears in the left hand side window pane, then right click that test case and chose "Properties", there are two properties available ... one of them is "Title".
The IDE allows one to create separate titles for each test case, even if you have included the same test case twice.
For example, I might have a script where I want to login twice (just an example only to serve the purpose of this question).
I could provide a title for the first instance of the login.html test case as "1st login", then add some test case, logout, and login again ... then title the second instance of the login.html test case as "2nd Login".
This is very handy. However, I want to be able to access the title value in the test itself. In that way, I might know that I am on the first or second instance of the same test case file.
I know some of you may have other opinions about how to accomplish the goal, but keep in mind, I am only using this as an example ...
I want to find out if the "Title" is available to me programmatically during a test run.
I'm not sure I understand your question, but maybe this can help.
"storeLocation" command is useful to store current selected window's URL in selenium IDE. The web application's URL will be stored into variable "varTitle1" and you will be able to use that variable value anywhere in your script.
*Command - Target*
open - https://www.google.com
storeLocation - varTitle
echo - ${varTitle}
"storeTitle" command is storing title of current opened software web application's title. It will store current selected windows title in to variable "varTitle2".
Command - Target
open - https://www.google.com
storeTitle - varTitle2
echo - ${varTitle2}

Safari extension: how to get current url from injected script?

I am trying to get the current url from injected script but it seems impossible because of the permission.
From the official document, I got:
Injected scripts cannot access the SafariApplication or SafariExtension classes.
Is there any solution or w/a? Thanks.
Use window.location.href to get the URL of the page the script is injected into.
Scripts are injected into each iframe as well as the main page, so you might want to use a check like if (window == window.top) to if you are only interested in the main page.

Is there a way to get a QTP to fail a test if a particular element appears on a web page

I am trying to test a JSP based web application with QTP. On some of the pages the JSP is coded to return a particular div element, which will have an ID attribute, to the browser, only of the underlying model has a certain boolean flag set. I'd like to be able to develop a QTP test that fails if the div is present in the returned web page. However, the QTP documentation doesn't seem to have any details on how to do this.
The point is to detect if the condition applies and then explicitly fail the test.
If Browser("b").Page("p").WebElement("html tag:=div", "html id:=theId").Exist Then
''# Report failure
Reporter.ReportEvent micFail, "Element Exists", "It shouldn't"
''# if you also want to stop the test
ExitTest
End If
The default behavior for QTP is to write in 'Report' when a check point fails. i.e. if an element is not found on the page , automatically the QTP will write in the log report. In order to disable that , and to customize your report depending on your test scenarios, you can disable the report logging from the
beginning and write only in case you found an abnormal behavior.
Reporter.Filter = rfDisableAll
'check point validations
Reporter.Filter = rfEnableAll