When I redirect to Blank Page I will test this page is blank page but In cypress , I don't know keyword to verify.
this is DOM I will check role if role is not admin, it will don't show anything but role is admin, it will show text This Page Is Correct
I want to create cypress to check if role isn't admin and page is blank page, but I don't have idea to verify this is blank page
"{user?.role !== "admin" ? ( <></> ) : ( <form <> This Page Is Correct </> )}"
enter image description here
What keyword I should use to check blank page.
You would have to check exactly what HTML you get in dev-tools (Elements tab) for a blank page, but this will kind-of do what you want to do.
if (user.role !== 'admin' ) {
cy.get('body')
.should('not.contain', 'This Page Is Correct')
} else {
cy.get('body')
.should('contain', 'This Page Is Correct')
}
If you find the text is there for both roles, but is hidden for non-admin, you could add
.and('not.be.visible')
...
.and('be.visible')
Related
i am working on PTC script where i am facing problem.when i view third page or second page ads then after confirming ad it will automatically redirect back to ads page but i want to redirect it back to the current page(for example if i view second page ad then after confirm it has to redirect to second page)
Here's the code.
UserAdvert Controller.php
session()->flash('message', 'This Ads Has Been Successfully Viewed.');
Session::flash('type', 'success');
Session::flash('title', 'Earn Successful');
return redirect()->route('userCash.links');
}
public function cashLinkShow($id)
{
$advert= Advert::findOrFail($id);
return view('user.viewads.showads', compact('advert'));
}
Route.php
Route::get('user/cash/links', 'UserAdvertsController#cashLinks')->name('userCash.links');
Route::get('user/cash/link/show/{id}', 'UserAdvertsController#cashLinkShow')->name('userCashLinks.show');
Route::get('user/cash/link/confirm/{id}', 'UserAdvertsController#cashLinkConfirm')->name('userCashLink.confirm');
Route::get('user/cash/links?page=links', 'UserAdvertsController#cashLinkPage')->name('userCash.links.page');
Site is redirecting to this address after viewing ads
Route::get('user/cash/links', 'UserAdvertsController#cashLinks')->name('userCash.links');
but i want to redirect back to the current page from where ad is view i created route for this
Route::get('user/cash/links?page', 'UserAdvertsController#cashLinkPage')->name('userCash.links.page');
but i don't know how to get parameter of paginated page.. kindly help me to resolve this issue.I am beginner in laravel thanks
You should try this:
use Redirect;
return Redirect::to('/user/cash/links');
I want to create a joomla 3.x template which shows a different UI on the homepage than on all the oder pages.
This works fine with the following code:
$app = JFactory::getApplication();
$menu = $app->getMenu();
$lang = JFactory::getLanguage();
$isHomePage = $menu->getActive() == $menu->getDefault($lang->getTag());
When I click on a menu item $isHomePage is "false" and I can show a different layout.
But when I open an article from the featured articles-list on my home-page, the menu item is still the home page but the user does see the article.
How do I get the information, if the user is really on the home page?
As per my understanding, the home page condition getting true on inside page is due to the fact that if an article does not have any menu it gets it from the current menu. So clicking on home page article link carries home page menu id.
There are some alternative that I can suggest -
1) Checking for URL - Check if current URL is equal to site page URL.
$uri = JUri::getInstance();
$currentUrl = trim($uri->toString(),'/');
$homeUrl = trim(JUri::root(),'/');
$isHomePage = $currentUrl == $homeUrl;
2) Check for homepage parameter with inner pages parameters. For example, if your homepage is of the article and having id X, check from request params check option and id param to com_content and id == X.
I hope this might be helpful.
I am generating my own Wordpress template and would like to give users a front-end form (so they don't have to log in to the wordpress dashboard) to submit some post content. I've got everything working, thanks to this tutorial - but I'd like to make one enhancement. Currently when the user presses submit the data is stored in wordpress and they are then redirected to a fixed URL of my choosing. Rather than this I would like to simply clear the form data and display a confirmation message - I guess via AJAX? I know there are built in AJAX capabilities in wordpress, but I've never really used it. Can anyone help me out?
The part of the code that submits the data to Wordpress and provides the URL to be redirected is copied below. I assume I wil need to make a change here?
$post_id = wp_insert_post($post_information);
if($post_id)
{
wp_redirect( '/thanks' );
exit;
}
You could simply redirect to the current page with get_permalink():
if ( $post_id )
{
wp_safe_redirect( add_query_arg( array( 'thanks' => '1' ), get_permalink() ) );
exit;
}
To display a message in the template, check the query arg:
if( isset( $_GET['thanks'] ) && '1' == $_GET['thanks'] )
echo '<p class="success">Thanks!</p>';
if you need more featuredone means, try this,
http://kvcodes.com/2014/02/front-end-post-submission-wordpress/
I just try to prevent re submission problem when refresh form page. so I use session flashdata() method and redirect same form page. but I want also display recent inputed data on form VIEW page. then I am try $this->db->insert_id() on my form VIEW page . but it always show 0. how can I solve it?
when you redirect the user after the successful form submission then add the parameter in the url just a exapmle with dummy code to make an idea for you
$insertedid=$this->my_model->add_info();
//your add_info() should return the inserted id
redirect("/myformcontroller/myformpage/".$this->db->insert_id());// add id in redirect url
on your myformcontroller controller's myformpage function
function myformpage() {
$insertedid=$this->url->segment(3);
if(!empty($insertedid)){
//get new added information and pass it to view
}
// your other code
}
hope it makes sense
I have a form on a web page, with one field to enter a code, to search for a property.
On clicking 'submit' I want to be able to run a script in the background without leaving the page.
The script will need to run a MYSQL statement which will have one of these results:
The property code does not exist, so display a Javascript Alert saying it does not exist.
The property is for sale, so call an existing javscript function 'saleSubmit(propertyCode)' to overwrite the exsiting web page with a new page sale.php for that property code
The property is for rent, so call an existing javscript function 'rentSubmit(propertyCode)' to overwrite the exsiting web page with a new page rent.php for that property code
The property is for sale and rent, so display 2 checkboxes within a div on the page to choose either the sales details or the rental details.
Can anybody point me in the right direction here?
Hi Nick - I think I screwed the system up a bit as I initially posted a question, then created an account which would not let me comment on the thread.
The status of the query is as simple as: does not exist, sale, rent, sale & rent
Extra advice would be really appreciated as I am problems googling for examples or a tutorial to point me in the right direction.
I first took this approach when I was looking at this problem to check that the form and Select statement were working correctly. So my form code looked like this:
<form name="idsearch" action="" method="post" onsubmit="xmlhttpPostForm('includes/idsearch-response.php', 'idsearch', 'idSearchResult', '<img src=\'images/loading.gif\'>'); return false;">
<input type="text" id="idRefNo" name="idRefNo" value="Enter Property Code" onfocus="this.value='';" />
GO <input type="image" src="img/template/search2.gif" alt="Click to Search for Properties"/>
and the php code called looked like this:
$idRefNo = $_POST['idRefNo'];
$query = "SELECT DISTINCT * FROM property WHERE property.Title = '".$idRefNo."' AND suspend != 'Yes'"; $result = #mysql_query ($query);
if ($result) { // If the query runs ok
if ($result != "") {
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
if ($row["BaseRental"] > 0 AND $row["Saleprice"] > 0) {
echo 'This property is for RENT and for SALE <br/>';
} else if ($row["BaseRental"] > 0) {
echo 'This property is for RENT only <br/>';
} else if ($row["Saleprice"] > 0) {
echo 'This property is for SALE only <br/>';
} else {
echo 'DOH! What is going on here!!! <br/>';
}
}
As I said above I would appreciate it if you could point me in the right direction to achieve what I want to do at the beginning of this thread.
First of all let's differentiate between the page(client) and your mysql database(server). Your page will have to send some request to your server which triggers a script to query the database. The result of that query is returned as a response to your page.
You could send a request by using javascript and the xmlhttprequest or try jquery which offers very simple methods to make requests ($.ajax(...)).
Your server and the script which queries your db should then return some meaningful status back to your client which has to interprete the result: Doing alerts, showing your div or whatever you'd like to do. I suggest returning the response as json which can be directly used in javascript without any parsing hassle. If the status of your query as simple as: does not exist, sale, rent, sale & rent. You could go as far and encode those as plaintext numbers, no json needed.