logout not working in IPAD - django

Really weird think happening with my site!
I have a "welcome {{user.email}}" in the top of my base.html page! So far was working fine, but when I tested the site in a IPAD2 and Iphone4, I saw that, the login part wasnt working right!What I mean by that is, if I am logged in the welcome message has been showing, but if I logout, some pages are still showing the welcome message in the top, but if I reload the page then it works fine afterwards! It seems that JUST ipad is holding some kind of cache! is it that even possible?
Just for record I am not using cache in my django app! my settings.py file has:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
So, I know that django is not messing things up! it is something with ipad!(client side)
does someone have a clue about it?!
EDIT
I tried already adding;
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
and
<meta http-equiv="Cache-control" content="no-cache">
no success so far though.
EDIT2:
This is happening in Safari also! but just in Safari and MAC os!! using Safari in windows works fine!

you're probably holding it wrong...
if you really think it's client side maybe you can try to add some meta tags for cache control and see if that helps.

Related

Make choregraphe app predefined Pepper naoqi 2.5

I have an application to host a webpage that will be the menu of the robot so I need it to be executing all the time unless my other apps are on use.
I have tried with trigger condition = 1:
Nature = Interactive: The app block other interactive apps such as face recognition and will not execute if other apps are running.
Nature = Solitary: The app is stopped when other interactive apps start (for example when a face is recognized)
The only important part of it is on the html part so maybe the approach is not correct.
I solved it by using:
Interactive nature with trigger condition as "1": makes the app run under any circumstances. (Solved in this stack overflow thread)
Setting my appplication's behavior as default: with this the app will start after every boot and it is important to mention that this is the only app (designed by me) running by default
calling the other behaviors with switch focus instead of runBehavior: by switching the focus the next behavior will run and when it finishes, it comes back to the menu.
Here is the code that I used (it doesn't work here because you need to download some software before):
var session = new QiSession(function(session) {
console.log("Connection esterblished!");
}, function() {
console.log("Could not connect to the robot");
});
function open_app(behavior_name) {
session.service("ALAutonomousLife").then(function(ALAutonomousLife) {
ALAutonomousLife.switchFocus(behavior_name, 1)
}).then(
console.log('Application cannot be switched to')
)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Question Page</title>
<script src="/libs/qimessaging/2/qimessaging.js"></script>
</head>
<body>
<button class="app-button" onclick="open_app('mynewapp-5d8038/.')">Open app</button>
<!-- "mynewapp-5d8038/." is the direction to the behavior you want to run, not the app-->
</body>
</html>
Hope that someone else finds this info useful.
In Choregraphe, you can set your installed behavior as "default".
The Default Behaviors are played automatically at robot startup.
Also note that trigger conditions express when an app can be run, not when it should or must.
You probably want to develop the application as a service outside of Choregraphe. General robot-jumpstarter toolkit may be useful for creating a template here. You may look at an example application creating a service and a webpage to display subtitles of what Pepper says at NLPPepperTools.

Selenium webdriver - Python won't click a button on a website

This is my first question on Stack Overflow. I am not much of a programmer, I just learnt about Selenium and went as far as I could but there is this mistake I can't fix alone so I am asking for help. I am using Python 2.7 in PyCharm.
As of now, I have been using anything.send_keys(Keys.ENTER) to click some buttons in my code as the .click() function always returned me a ElementNotInteractableException error in Chrome for this website. The goal here is simply to clear a text area, insert the list of genes down there and click on this "submit" button. This is supposed to show me an updated table that I want to download.
For this one troublesome button though, nothing works. The thing is, it doesn't even return an error, the code keeps going on as if it indeed had clicked, and it eventually downloads the non-updated table. I tried switching to Firefox, where neither .click() nor .send_keys(Keys.ENTER) worked (I never get an error as well, it just downloads the wrong table). Clicking myself does work and produces the updated table.
Based on other questions I saw here, I tried using ActionChains or scroll_into_view but still, nothing happens. Here is the code :
baseline_url = "http://mtsspdb.noble.org/atlas-internal/3880/transcript/profile/5?charttype=barchart&sessionid=1553076490500118&feature_accs=%20Medtr1g079760.1"
driver = webdriver.Chrome("C:\Webdrivers\chromedriver.exe")
driver.set_page_load_timeout(30)
driver.get(baseline_url)
driver.maximize_window()
peptides_list = """Medtr4g068220.1
Medtr1g107390.1
Medtr1g018740.1
Medtr5g016470.1
Medtr4g095002.1
Medtr5g004930.1
MT4Noble_020581.1
Medtr1g107395.1
Medtr1g107400.1
Medtr1g107405.1
Medtr1g107410.1
Medtr4g095010.1
MT4Noble_057127.1
"""
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH, "//*[#id='feature_accs']")))
text_area = driver.find_element_by_xpath("//*[#id='feature_accs']")
text_area.clear()
text_area.send_keys(peptides_list)
time.sleep(1)
troublesome = driver.find_element_by_xpath("//*[#id='form1']/div[8]/div/input")
print troublesome
#scroll_into_view = troublesome.location_once_scrolled_into_view
ActionChains(driver).move_to_element(troublesome).send_keys(Keys.ENTER)
time.sleep(3)
print "Sucess for x"
The html location of this button is
<input class="btn btn-primary" type="submit" name="submit" value="Submit">
Do you have any idea on how to click it, and most of all on why it doesn't work ?
Many thanks
PS: As I said previously, it is my first question. Please tell me if I need to update/change something.
This will definitely work, as I just tried it given your information
driver.execute_script("$('#form1').find('.btn-primary').click()")
Now, there must be something strange about it finding the element, as Selenium would error if it could not click. So the element we are clicking with the code must not have the events we expect it to have. I am investigating more and will update this with specifics.
Edit:
Interesting. The submit button does not seem to have normal event listeners.
getEventListeners($(".btn-primary")[0]);
$._data($(".btn-primary")[0], "events");
Both of these return nothing. This would seem to be the cause of the Selenium issue. It isn't triggering the actual submission with its click. Selenium does not use Javascript, and also does not use a real user32.dll (Windows ex) click, so it does not always behave identically to a real click or a javascript click.
Welcome to SO. Here is the option to click on the button.
Option 1: click using javascript
driver.exeucte_script("arguments[0].click();",troublesome)
Option 2: Scrolling to element
troublesome.location_once_scrolled_into_view
troublesome.click()
This works well for me:
for i in range(1, 10):
try:
driver.find_element_by_xpath(
f'/html/body/div[{i}]/div/div[2]/span[1]/span/span/input').click()
except:
pass

Problems with MSF4J and #MatrixParam

Folks, I have found what seems to be a problem with / (bug in ?) MSF4J as including an #MatrixParam annotated variable in a URI causes the affected (micro)service to either 'hang' indefinitely, or if accessed via a browser, to give a "404 Not Found" message for the path/endpoint, even when correct.
Here is a code fragment that illustrates the problem - it compiles ok (eclipse/maven) and deploys without errors using microservicesrunner() in the usual way.
package org.test.service;
import javax.ws.rs.GET;
import javax.ws.rs.MatrixParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
#Path("books")
public class MPTest { // MatrixParam Test
#GET
#Produces(MediaType.TEXT_PLAIN)
#Path("/query")
// method to respond to 'GET' requests
public Response getListOfBooks(#MatrixParam("Author") String author) {
// do something in here to get book data from DB and sort by titles
List<String> titles = .......;
return Response.status(200) .entity("List of Books by " +author+ "ordered by title " + titles).build();
}
}
With this code fragment, accessing the URL "(host:8080)/books/query;Author=MickeyMouse" should cause a list of books by that author to be retrieved from the DB (I have omitted the actual code that does so for clarity, as it is not relevant to this post).
However, it does not get there, so that code isnt executed. As far as I can tell with a debugger, no #MatricParam value is retrieved - it remains null until the process times out. Things like curl and wget just hang until they time out, and from a browser, the best I can get is a 404 not found error for the URI, even though it is valid.
However, if I replace the #MatrixParam with a #PathParam it works perfectly, and can I get the URL string retrieved in its entirity. The URI that I get is as expected - no odd hex characters, no typos, and so forth. The URI entered is what you get back. So, no problem there.
Behaviour is also consistent across platforms (couple of flavours of Linux, and three versions of Windoze), so it is not anything to do with the OS itself. Similarly, I get the same behavior with multiple clients and tools, so it isnt a problem there either.
So, it appears to be a problem within the MSF4J framework / domain, and I could use some support / help / suggestions here as I've reached the point of tearing my hair out..... Any ideas, folks?
The only reference I can find to a similar problem was closed as 'off topic' without a reply (see Rest API Matrix param annotation) so I think that this needs re-opening as it seems to be a genuine problem....
Regards, and thanks in advance for any help,
Rick
#MatrixParam is not supported with MSF4J at the moment. You can create a GitHub issue. So we can implement that support in future releases.

Capybara/Poltergeist DOM loading issues

I am writing a test suite using Capybara/Poltergeist combo for a website and I am coming across a situation where the DOM doesn't seem to be loading whatever I try to do.
I can see from the website snapshot that only the footer and the header are there, but not the main components of the page.
for example a page such as: https://www.udemy.com/courses/business/finance/all-courses/?lang=en&ordering=newest
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, js_errors: false, debug: false, # change this to true to troubleshoot
window_size: [1300, 1000] # this can affect dynamic layout
)
end
browser=Capybara.current_session
browser.visit "https://www.udemy.com/courses/business/finance/all-courses/?lang=en&ordering=newest"
sleep 15 ##giving it time to load
browser.save_screenshot('app/file1.png', full: true)
only the header and footer show up.
I suppose it is due to the fact that some DOM elements are loaded asynchronously, and on my current website I have the same problem.
Stuck here for 2 days now, any suggestions as to how to get the page to load properly? Thanks
You most likely need to update phantomjs to 2.0+. PhantomJS 1.9.8 which I'm guessing you're using is roughly equivalent to Safari 5 iirc and doesn't appear to work with the udemy site.

QWebView - Error 400 when giving url

I'm trying to build a little application that needs to run the url that is generated by the script at this link: http://blogs.aws.amazon.com/security/post/Tx70F69I9G8TYG/How-to-enable-cross-account-access-to-the-AWS-Management-Console
The application is build with Qt4 and Pyqt4. I create a QWebView and want to load the url that is generated at the end of the script in the link inside the webview.
url = QUrl(ConnectionScript.generateURL())
self.webView.load(url)
self.webView.show()
but this code gives me a "HTTP Status 400 - BadRequest" error. I've tried to change the "load" with "setUrl" but there is no change.
The useful code is only this, other lines are just setting up the GUI (and it's doing fine). Any suggestion about how to fix this and what might the problem be? I think it's something very easy to fix but i can't do it right...
Edit1: i forgot to mention that when i open the generated link in a web browser (like chrome or firefox) all goes well and it gives me no such error
Found out that the problem was this line of code:
request_parameters += urllib.quote_plus("https://console.aws.amazon.com/")
The quote_plus encoded : / so the webView load couldn't process the url in the right way.
Just don't use the urllib.quote_plus method and everything will go as expected.