Sorry for the trivial question, but how to share steps in Robot Framework (pyCharm)? I have a test case that covers loging into account (login.robot) and another test case that conducts an action after logging in. How do I use the steps from first case so I don't have to write them again? Should I put them in 'Resource' file? Or set as resource that case 'login.robot'? Or maybe put it in 'Keywords'?
Thanks in advance for the help!
You need to create a keyword to perform login and use it in both of your test cases. In second test case the keyword could be part of setup. Below is just a rough exmaple
*** Settings ***
Library Selenium2Library
Resource C:\\development\\robot-scripts\\sshlibrary\\login.robot
*** Test Cases ***
Open the Login Page of Yahoo Mail
Open Login Page
Close Browser
Resource File
*** Settings ***
Documentation An example resource file
Library Selenium2Library
*** Variables ***
${HOST} mail.yahoo.com
${LOGIN URL} https://${HOST}/
${BROWSER} gc
*** Keywords ***
Open Login Page
[Documentation] Opens browser to login page
Open Browser ${LOGIN URL} ${BROWSER}
Wait Until Page Contains Element //*[#id="mbr-login-greeting"] timeout=60s
As advised, please go through the robotframework user guide for this.
Related
I am validating a few URL's together using data driver and some are getting redirected still prints 200 response. In this case, the test case needs to fail and mention the reason for failure.
Any leads would be appreciated.
Code snippet:
create session current_session ${URL}
${Response}= get request current_session /${gmail}
Here, I need to verify, if the URL has navigated to right page without any redirection. I using the data driver library.
I think you should separate your test cases. You should have one (or more) for verifying the response body and another one for verifying the URL redirection.
For the latter one I would definitely use SeleniumLibrary.
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Redirect Test
Open Browser https://stackoverflow.com/ Firefox
Location Should Be https://stackoverflow.com/
[Teardown] Close Browser
But if you would like to use RequestsLibrary for that one as well, the returned object has an url and a status_code attribute that could be used for verification.
*** Settings ***
Library RequestsLibrary
*** Test Cases ***
Redirect Test With Requests
Create Session SO https://stackoverflow.com/
${response}= Get Request SO /tags
Log ${response.status_code}
Should Be Equal As Integers ${response.status_code} 200
Log ${response.url}
Should Be Equal As Strings ${response.url} https://stackoverflow.com/tags
[Teardown] Delete All Sessions
I have to record a load test for a successful login and further browsing in to the asp.net application.
After recording the script in jmeter, my samplers are 1) get request (login page) 2) post request (posting the credentials and click login) 3)and other samplers (after successful login).
My problem is it shows incorrect username password error(manually it is working) whenever i play the the script, i have parameterized the valid credentials, also did correlation(by seeing the post request i got to know the fields that were posted) with event state validation, viewstate genearator, viewstate and hdnkey from get response(sampler 1) to my post request(sampler 2) and tried again, but i am getting the same error everytime.
Please let me know, what should be done to login successfully. So i can perform the load test on this asp.net application.i have came accross lots of sites for this issue but nothing solved it. Please help!
You can try to debug your JMeter script. Look here and here. I would use Debug Sampler as the first step for seeing variables values.
You can use tool like Fiddler to record the requests that are made when you manually login into the site. Then you can compare them with your JMeter script.
Make sure to add HTTP Cookie Manager to your Test Plan
Make sure to correlate any dynamic parameters like View State, EventValidation, etc.
Run your test with 1 virtual user and 1 loop and inspect request and response details using View Results Tree listener. Compare requests you send with JMeter with what real browser sends (can be found in your browser Developer Tools "Network" tab") - requests should be the same (apart from dynamic parameters)
Check out ASP.NET Login Testing with JMeter article for example test plan building explained.
I had a working wp-piwik plugin. Its configuration looked like this:
It worked fine. Then I moved the piwik installation to a different location (so I can track more sites).
Now wp-piwik only recognizes the auth key if we're not using a /home... path, but http://analytics... path. And unfortunately it doesn't work - no tracking occurs.
If I give a wrong URL, it sees it's wrong.
If I supply a wrong auth token, it sees it's wrong. So somehow the plugin communicates with piwik.
If I supply piwik location as a /home/piwik/, it doesn't work, and I'm pretty sure it used to work before I updated from 2.3.0 to 2.7.0.
My site works fine with the tracking code. But that is visible in the browser and I don't like that. I don't want the tracking to depend on the user's browser. I don't want the client to know that there's tracking.
If there's manual php code inclusion that I can use. I'd use it, but i'm not very good with php.
The option "Piwik path (PHP API, beta):" works only if I remove the auth token but also doesn't track. the piwik path can only be /home/piwik....
Here's what Support --> "Run test script" gives me:
*** Test 1/2: SitesManager.getSitesWithAtLeastViewAccess ***
Using: cURL
SSL peer verification: enabled
User Agent:
Call: /home/user/piwik_location/?module=API&method=SitesManager.getSitesWithAtLeastViewAccess&format=XML&token_auth= + TOKEN
Result:
Time: 0s
*** Test 2/2: SitesManager.getSitesIdFromSiteUrl ***
Using: cURL
SSL peer verification: enabled
User Agent:
Call: /home/user/piwik_location/?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=http%3A%2F%2Fsite.com&format=XML&token_auth= + TOKEN
Result:
Time: 0s
Any suggestions?
You also have to update the trusted hostname if you move Piwik:
http://piwik.org/faq/troubleshooting/faq_171/
If this does not help, check WP-Piwik's debug script output (see support tab in settings menu).
UPDATE: As discussed here (https://wordpress.org/support/topic/wp-piwik-recognizes-the-key-but-doesnt-track-with-piwik-url-or-piwik-path?replies=7), the plugin's behavior is as expected. The test script output above shows the wrong value for Piwik URL (it contains the path instead). If entering the Piwik URL and enabling the tracking script, the tracking works.
In my Drupal installation I often need to login 2 times to get logged in.
This is the case when I go exactly this way:
open a new incognito window in browser (in my case Chrome)
try to login -> login failed with no message
try to login 2nd time -> logged in
close the window WITHOUT logout
open a new incognito window in browser and try to login -> login failed
When I logout and try to re-login, the login works.
There are some more randomly cases where the login doesn't work too at the first time. But these cases I can't describe exactly.
In Drupal log and Apache log I don't get any message after a failed login.
Where can I start my search to solve this? Or does anyone had the same problem?
The session cookies are stored by drupal to confirm users as being logged in. Check the developer tools in chrome to asses whether a cookie has been or was meant to be stored. Icognito Mode makes a point of treating cookies with deference (might also be the general settings of your browser).
Try setting your cookie domain settings.php. Depending on your hosting or setup this sometimes needs to be done to make sure cookies are working correctly.
Basically you will add a line like
$cookie_domain = '.my_site.com';
Do not add a trailing slash and do not remove the leading period (this is documented and commented out in settings.php, do a find for $cookie_domain and you should see it.
https://drupal.org/node/1844574
First I have added HTTP proxy server and recorded whole login and logout action.
after running script in view result tree, i have selected HTTP(downloaded) but in response data it is displaying an error message to enter your email address and enter your password error.
Please help me to solve this problem.....
Note: Username and password fields are in home page. So, i have to login through home page.
First of all try adding a HTTP Cookie Manager to your Test Plan which should be smart enough to deal with sessions and cookies.
I also recall that ASP.NET powered websites require dynamic parameter called VIEWSTATE or something like that. You'll additionally need to add some correlation to your tests, t.w.
Open Home Page
Obtain VIEWSTATE value via Regular Expression Extractor Post Processor and store it to a JMeter Variable, i.e. ASPNET_VIEWSTATE
Add a corresponding parameter to next request in "Parameters" stanza as VIEWSTATE = ${ASPNET_VIEWSTATE}