How to activate loader page while running selenium code in python - javascript

I am creating a python flask web application with selenium in the backed I want to disable my webpage when the selenium driver is running to prevent user activity
I am using this code
<div id="disabler">
<div class="text-center">
<img src="{{url_for('static', filename='images/disabler.gif')}}">
<p id="preloader-text">Running Automated Test</p>
</div>
</div>
<script>
function loader(){
$(document).ready(function(){
$("#disabler").fadeOut()
});
}
</script>

When you are using new tab every time then it is not possible to hide. You can just put always on top feature for chosen window.

You can use a predefined jQuery UI called jQuery Block UI
Or simply add a division that will block the body and will fade out when the body is loaded.
<div id="div">
<h1>Please Wait..</h1>
</div>
jQuery will be:
$(document).ready(function(){
$("#div").fadeOut()
});

Related

How to access the webresource controls from another html webresource on CRM 2016 Form?

I have two html webresources in my customer form, one contains a multitab and second contains some tiles, designed using bootstrap and JQuery for events. Want to initiate a Click event of tab exist on first webresource on the click of tiles exist on second webresource.
I have prepared the script on simple html page first all code is working there but not on crm form.
How can I access the tab controls using JQuery from first webresource?
I have written some scripts on each html webresources, can I use the same script/function from another html webresource?
Webresource_1
//html
<div class="row">
<ul id="tab_container_01" class="nav nav-tabs">
<li id="tab_cases"><a id="ahref_cases" href="#">Cases</a></li>
</ul>
</div>
//script
//Following script is working fine on the same page
<script type="text/javascript">
$("ul.nav-tabs").on("click", "li", function () {
var selectedTabText = ($(this).find("a").text());
var tabs = window.parent.Xrm.Page.ui.tabs;
//Some toggle script
});
</script>
Webresource_2
//html
<div class="panel">
<div> Open Cases </div>
</div>
//script
<script type="text/javascript">
$(".panel").on("click", "div", function () {
// following not working on crm form
$("#tab_cases").addClass('active');
$("#tab_cases").parent().siblings().removeClass('active'); //length 0, id not detecting
//window.parent.$("#tab_cases").parent().siblings().removeClass('active');
/* trigger click event on the li */
//trying to use function written on webresource_1 script
$("#tab_cases").closest("ul.nav-tabs li").trigger('click'); //*Not Triggering*
});
</script>
Although, technically since you are all within CRM, and you won't have any Cross Domain Scripting issues, this may be a little over kill, you could use Window.Post Message from Frame1, to communicate to the CRM form, and then have it communicate to Frame 2. This would also mean that your scripts wouldn't have to be dependent on the DOM of each, other subscribe to the same interface for posting/receiving messages.

impact of js script a the end of the html page

In a html web page, i load in my main section the content of another html page. I have a js script section at the botton of my charged page. I use jquery.
<div id="main">
</div>
Other page
<div>
...
<div id="roomCheckoutResult" class="hide">
...
</div>
</div>
<script>
$('#dateRoomCheckout').datetimepicker({
format: 'DD/MM/YYYY'
});
$("roomCheckoutResult").show();
</script>
Line with function show don't work. If i use directly
document.getElementById("roomCheckoutResult").className="";
that work.
So why my line with show don't work.
You need to change this:
$("roomCheckoutResult").show();
to this:
$("#roomCheckoutResult").show();
You target an id value by using a # at the start of the selector.
And, it goes without saying that you have to make sure that jQuery is loaded before using it.

JQuery find element in script

I am really not great at web stuff, so I am apologizing in advance for a potentially poor explanation of my problem.
Basically, I have a webpage which utilizes the handlebars js templating. Unfortunately, this means that many of my div elements are contained within javascript tags like the following:
<script type="text/x-handlebars" data-template-name="index">
<div class="row intro">
......
</div>
<div class="descript">
.....
</div>
</script>
My intent is to grab one of these div elements using jquery.find(), but from what I understand, the html within the script tags is not treated as part of the dom...so jquery does not see it as a dom element. I was wondering if there is any other way I could go about this. Some more code is included.
Here is another more explicit explanation in case the one I gave above was a little muddled: I am working on a personal website and would like to embed a project I have been working on in unity3d, but I need to add/remove elements based on whether or not the client has the unity3d web player installed. Normally I would get a particular element with
var $missingScreen = jQuery("#unityPlayer").find(".missing");
where 'missing' is simply an element inside unityPlayer which displays a link if the client does not have unity3d. I am also using some javascript templating to make my site look pretty and as a result, I have this problem:
<script type="text/x-handlebars" data-template-name="index">
<div class="row intro">
<div class="intro-text">Hi, I'm *****</div>
</div>
<div class="descript">
<p>
Here's a Project I have been working on in case I am of interest to you:
</p>
</div>
<div class="content">
<div id="unityPlayer">
<div class="missing">
<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
</a>
</div>
</div>
</div>
<p class="footer">« created with Unity »</p>
</script>
Jquery cannot access the missing element. Is there any way to do this? Thanks for any help you can give me and sorry again for my inexperience.
EDIT* some people might want to know: here is how I determine whether or not to show the missing div. Another note; everything works fine if I remove the script tags...it is only when I put html within the script tags that it becomes inaccessible to jquery.
jQuery(function() {
var $missingScreen = jQuery("#unityPlayer").find(".missing");
$missingScreen.hide();
u.observeProgress(function (progress) {
switch(progress.pluginStatus) {
case "missing":
$missingScreen.find("a").click(function (e) {
e.stopPropagation();
e.preventDefault();
u.installPlugin();
return false;
});
$missingScreen.show();
break;
case "installed":
$missingScreen.remove();
break;
case "first":
break;
}
});
u.initPlugin(jQuery("#unityPlayer")[0], "temmp.unity3d");
});
Instead of
var $missingScreen = jQuery("#unityPlayer").find(".missing");
I would try out
var $missingScreen = jQuery("#unityPlayer").children(".missing");
or
var $missingScreen = jQuery("#unityPlayer .missing");
Don't forget the space between Player and .missing!
I hope it works.

jquery change content of page by clicking button on the second page

I have 2 php files and one jquery file (2 php files include that jquery file). How to change content of 1 page by clicking button on the 2 page using jquery(without refreshing pages). for ex: on button click send div (2 page) to the div (1 page). OR maybe use 2 jquery files or any other techniques. code demonstration would be perfect. my code:
ex2.php
<script src="ex2.js"></script>
<title>Ex2</title>
</head>
<body>
<button class="show"> show </button>
<div class="showdiv"> show </div>
</body>
ex3.php
<script src="ex2.js"></script>
<title>Ex3</title>
</head>
<body>
<button class="save"> Save </button>
<div class="savediv"> Save </div>
</body>
ex2.js
$(document).ready(function(){
$(".save").click(function() {
$(".showdiv").after("<p>GGGGGGGG</p>");
});
$(".show").click(function() {
$(".showdiv").after("<p>BBBBBBBB</p>");
$(".savediv").after("<p>BBBBBBBB</p>");
});
});
AFAIK this type of "push" is only possible when you have a highly complex system involving server-side services and hooks on the receiving pages that are listening for changes to those services. This question is accordingly too broad and probably too complicated for a simple answer, as per StackOverflow guidelines.

How can I fade-in and fade-out between two contents on same page using javascript?

I am developing a page in JSP. It has 3 components: Header, Content and Footer. I want that when this page loads the Content part should be fade in to default content i.e. the Home Page, which contains button for register, login and site credits. When user clicks register button, the content in Content part should fade out and vanish and then content of register form should fade in and get displayed. Same for other buttons, but there should not be any change in header and footer. Please help!!!
With use of jQuery... You have working example there...
I'd recommend using a JavaScript library to achieve this.
jQuery has built in fading abilities.
<div id="clickme">
Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123" />
With the element initially hidden, we can show it slowly:
$('#clickme').click(function() {
$('#book').fadeIn('slow', function() {
// Animation complete
});
});
Using JQuery, you can hide a div by using a selector and the hide() method. For example:
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function swap_divs() {
$("#div_to_hide").hide();
$("#div_to_show").show();
}
</script>
<body>
<div id="div_to_hide">
Some text for div to hide
</div>
<div id="div_to_show" style="display: none;">
Some text for div to show
</div>
<button onClick="swap_divs();">Click me</button>
</body>
</html>
If you look at the JQuery website you can find more example and extensive documentation. Also for fading in/fading out.

Categories

Resources