I am designing an automation framework for a web based application. I have used 'Exist' method to check if the user has correctly logged into the application. Something like this:
If Browser("XXX").Page("YYY").WebElement("Either you have entered").Exist(0)
Then
Browser("XXX").Page("YYY").Image("btnok").Click
fnReset = false
Else
If Browser("XXX").Page("YYY").WebElement("Account Search").Exist(0) Then
fnReset = true
End If
Browser("XXX").Page("YYY").Sync
End If
This code works fine , if an invalid username/password is entered as it hits the IF part first.
However, when I try with a valid username/password, the IF condition step keeps running for a long time and the ELSE part is not getting executed at all.
Is there an issue with the timing for which the test waits or is there any other problem?
Could it be that the "Either you have entered" exists even when the login succeeds but isn't visible to the user? Perhaps it has hidden=true. Try to login successfully manually and then highlight that WebElement from the Object Repository. If it doesn't complain that the object does not exist the condition you're using for detecting successful login isn't correct.
Related
The DialogFlow CX with Page Form Parameters was working well in the test simulator and recently, my chat bots are not responding after user inputs.
When i tried to troubleshoot the issue i realized that the $page.params.status='FINAL' or the $page.params.someparameter.status='UPDATED' events are not firing properly. Due to this the routes are getting failed.
Initially i thought the issue is in my Project. Then i tried the prebuilt agent (travel-baggage claim) in another project. Even that behaves the same without any response after the user inputs are collected.
I also reported this issue to the Developer Advocates in Twitter and updating here as well to get some response from the community.
I’ve tried to replicate your use case but I was able to successfully trigger the condition routes $page.params.status = "FINAL" and $page.params.parameter-name.status = "UPDATED" as expected and transition to the defined page from my end.
See the following for reference:
$page.params.status = "FINAL"
$page.params.parameter-name.status = "UPDATED"
To troubleshoot the issue, you may check if all the conditions defined in your condition route are fulfilled. Also, you may need to check if the condition rules applied is OR or AND. If AND, make sure that all conditions are fulfilled in order to transition to the defined page or flow.
As for the prebuilt agent Travel: baggage claim, I was also able to replicate the same behavior. However, I noticed that this is a different issue since the issue is caused by the webhook being unable to provide a response and not caused by triggering the condition route. I was able to verify this by adding a static response on the condition route and by checking the logs from the simulator. See screenshots below for more information.
Static response
Log snippet from simulator
I tried creating a new flow and migrated all the pages and it works well. I suspect the flow got corrupted when i programmatically tried to update via API.
I have been able to successfully download, compile, and run Shopizer. Unfortunately, when I attempt to display the home page, I get a blank page. By "blank" I mean that there is nothing on the page, not even undisplayable HTML!
I also attempt to log in as the admin. When I point my browser to the admin page (http://localhost:800/admin) I get the login page but when I enter the username and password (admin and password) the Shopizer throws an exception.
I am running this application in Eclipse, so was able to debug the code. I am finding that the exception from the admin login is caused by a failure of the application to read the username from the database. It attempts to get information from the database when you log in, but the query for information on the admin user returns null and that causes an exception to be thrown.
Apparently, it is getting nothing from the database. I am running this using the default H2 database configuration, and from what I have understood reading some of the information on their forum, the H2 database is run as an embedded database in this application. I also understand that on first running the database is initialized and test data is put in. I have also looked at the database file, it has data in it.
Yet for some reason, Shopizer fails to get user info about the admin user. I suspect that some of the other blank pages I am getting are caused at least partially by a failure to read product and other information, as well.
Does anyone know what is causing this failure to read the database? Has anyone else seen this behavior before? Is there something that needs to be done to enable access (Shopizer's documentation is somewhat incomplete so who knows what else might need to be done to make it work)? Or is there something that needs to be done to make it able to read the database?
Are you able to run the app from the command line first
cd shopizer
./mvnw clean install
./mvnw spring-boot:run
When running from eclipse once you have imported shopizer root project make sure the H2 file resides under sm-shop
Have you tried to configure mysql ?
Yes the schema is created and updated during startup
A web site I have published is generating the error stated below when a valid user submits form content to be stored in the database:
Forbidden
You don't have permission to access /index.php/user/add on this server.
Additionally, a 404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
This is a private web site. All users have to log-in. Some users can add content. Using CI sessions there is an added field of edit, with a value of 0 or 1 retrieved from the user's record in the user table, copied to the user_data session array at the time of log-in. The variable $this->session->userdata('edit') is used for if statements in the controller and views. Value of 1, user will see links that will bring up views (forms) to edit or add content.
This is a snippet for how I am using the variable to set menu items:
<?php if ($this->session->userdata('edit') == 1) { ?>
<li>Add</li>
<?php }; ?>
This is the basic structure for the processing of form data. This function is in the controller file user.php:
function add(){
if ($this->session->userdata('logged_in') ){
//runs form validation
if ( $this->form_validation->run() == FALSE ) {
//if false, redisplays the form and data with failed fields highlghted
}//if
if ($this->form_validation->run() == TRUE) {
//processes the data and stores in the database
}//form validation run
} else {
redirect ("user/login");
} //if...else
}//add
Examining the database after one of these Forbidden errors, no data is inserting. A redisplayed form due to validation error(s) is not happening either. These factors lead me to believe this is a server problem more than a CodeIgniter issue. If you look at this link it shows a screen shot of the error received in the browser (either Firefox or Chrome, other browsers not in use yet), it is not the usual CodeIgniter appearance for an error generated from a mistake in CI code.
The add/edit content forms are working well. As stated above, the error occurs at time of form submission. As well, it is only happening on the hosting company's server. I have checked the permissions of user.php and they are 644 like the rest of the files.
What are possible fixes? If it is a server issue, what do I look for or ask my hosting company to look at? If it is a CI sessions issue, in the documentation CodeIgniter states it uses a system different from $_SESSION super global. Is it wise to copy the user data to that array and have the code look up the data from that variable array? Or do I create a distinct array and save the keys there?
Revision and Solution
I retested the connection to the database associated with this project. I could connect. Taking things a next step, I could select records but not insert. I performed those tests with raw, simple statements.
Examining privileges for this user and the database, I discovered that while All Privileges was checked, none of the individual privileges was checked. (See this screen shot.)
I ignored the All Privileges check-box and manually checked each of the other boxes. Conducting small tests like the ones outlined above and then interacting with the form on the site, I am getting results I expect.
Things I don't understand:
How can All Privileges be checked and none of the other check-boxes checked?
I have gone back and tried to check All Privileges and then uncheck the others individually. It's not possible. From interacting with Panelbox on this host often to set-up users and associate them with a database, I know it is not usual for the state I found described above.
Programmatically, since there is only one user and set of privileges associated with a CodeIgniter site, how was the admin for this site able to insert 5 records in the database before a Forbidden error started being returned from the server?
I did not outline it when I first posted this thread, but the Forbidden error did not happen right away with uploading and running the site from the server. Since the admin was able to submit five completed forms perfectly before starting to receive errors, I presumed it was a Sessions problem. This contention was also arrived at because sometimes deleting the cookie and then logging in, I or the admin was able to submit a form and the data was inserted in the database.
Thanks for taking the time to read this.
Test user privileges associated with a database often. Sometimes things change.
I am using Cucumber to perform automated tests. I am running two features during a run where in I enter my credentials to perform an action in the website. When second feature is executed I will have to re-enter the same credentials but the browser had already stored my credential previously making the script to actually skip/fail at this step. I have shared my script below. Please advice what can be the solution.
I tried deleting cookies but still the problem persists.
When /^I clear cookies$/ do
browser = Capybara.current_session.driver.browser
browser.manage.delete_all_cookies
end
In this case, You need to reset your sessions which will allow you to re login again with out any issues!
in your code:
When /^I clear cookies$/ do
Capybara.reset_sessions!
end
Accept my answer if it works for you!
Starting a new browser session guarantees a clean environment. However, depending on your setup and test suite, it slow tests down too much, but you might want to try that.
Deleting cookies does not drop credentials if you logged in using HTTP basic auth. If that is the case, there's no other generally applicable way than to restart browser.
first, sorry for the bad english.
I have a test that submit a login form.
after redirect, when I test for a message 'successfully logged...'
then my page.body is
'<h1>Not Found</h1>'
but this works perfectly on browser manual test.
what should I'm doing wrong?
Sounds likely that one of your steps is redirecting in a way that you do not expect.
Check your before filters on the controller and application_controller to determine whether a login/I18n filter is redirecting your page.
If you have the launchy gem installed, you can also add the following to your steps:
And show me the page
Which will fire-up a browser with what capybara is actually looking at, which is useful for sanity checking your steps.
Good luck!
Tests run under their own clean copy of the database. Make sure you've set it up first using rake db:test:prepare, and that you're creating all the data you need for your tests as part of the feature. (I.e. Given there is a user named "Joe"...)