how to run multiple instances/tabs in a single chromedriver instance? - python-3.x

Goal:
open chrome driver
given list of known length urls array, open each url in its own tab and click a counter.
In the urls array list the last url has functionality to go to the page and check the final count.
This is to test websockets, that's why I want to test it in a single instance.
Current solution:
Have subprocess open with a new instance each time, but this is resource intense.
Trying to lower this resource eating by not opening another instance but rather working in the same instance.
Current solution:
Takes a medium time and most resource usage.
-> open driver -> go to page -> click counter
-> open driver -> go to page -> click counter
get urls[5] -> -> open driver -> go to page -> click counter
-> open driver -> go to page -> click counter
-> open driver -> go to page -> click counter
Wrong solution: takes longest time but least resource usage
open driver -> go to page -> click counter -> open tab -> go to page -> click counter ->
....
Wanted Solution: (theoretically) should be a little faster if not the same as the current solution, but medium resource usage. (the usage and time cut downs happen because of one less chromedriver instance opening and all tabs processing at the same time.
-> open tab -> go to page -> click counter
-> open tab -> go to page -> click counter
open driver -> get urls[5] -> -> open tab -> go to page -> click counter
-> open tab -> go to page -> click counter
-> open tab -> go to page -> click counter
So far I have tried implementing this in golang using chromedp, which has hard to read documentation and the library is very unstable.
The other method I have tried is python with chromedriver which is working very well but the issue is of saving as many resources as possible.
thanks a ton for any help toward the right direction!

Related

Create my #display

I have N modules that use same dropdown list (data I take from the server),
I want do something generic when I write #display.X()
that display the dropdown that I created,
what's the best practice to do that?
that's ok write the code into Themes -> TheAdmin -> Views -> X.cshtml?

Excel edit web query import button is disabled

Hi am trying to edit the web query in excel. It is calling a sql procedure
It is allowing me to edit the query and when I click on the GO button I can see the changes(column headers) as well in the popup. But the problem is import button is disabled. So I was unable to see the data changes in excel.
any ideas why it disabled ?
Solved the issue by updating the excel.
Open Excel -> File -> Account -> Office Updates -> Update Options ->
Update now
After updating the version is
Version : 1707
Build : 7766.2099

Strange permission behavior into nested folders

Plone 4.3.1 + Dexterity (p.a.dexterity 2.0.8, p.dexterity 2.1.3)
Folder structure: /Plone/A/B
I want A to be visible to loggedin users, and B to be manageable by userx (meaning he/she can modify/add/etc).
Usual approach:
A -> sharing tab -> logged in -> can view
B -> sharing tab -> userx -> can add
Then you go to B and you can do everything BUT add content.
But, if you give userx 'Contributor' role on the portal, it works. So, the role that he/she needs on the context is 'Contributor'. Ok, let's check it!
Go to debug shell, traverse to folder, check local roles: everything's ok! The user has the local role.
After a lot of attempts and combinations of settings I found that this works:
A -> add new menu -> restrictions -> change "use parent settings" to "use site default"
B -> add new menu -> restrictions -> "use parent settings"
Aaaaand... it works!
If I remember well, it never worked like that? Is this a regression that has been fixed later?
I think this is the bug we fixed on plone.app.dexterity 2.1.2.
https://github.com/plone/plone.app.dexterity/pull/127
You can upgrade to this version also on Plone 4.3.

Cannot find SpriteFont template using MonoGame in Visual Studio 2012 Express (with XNA 4.0)

When I right click Content folder of my project then Add -> new Element, in the dialog box, selecting XNA Game Studio 4.0 I see only 3 templates, which are:
content type writer
content processor
content importer
Since every tutorials that help in creating screen menus say that I should start by loading SpriteFont template, I think that I've missed something.
Any suggestions? Should I give you more informations?
You have to right click your Content project -> add -> new element. If you don't have a Content project you can create one, just right click on your solution -> add -> new project -> XNA Game Studio 4.0 -> Empty Content Project (4.0)
You have to click the solutionname Content node and not the solutionname node. The new items result is based on that.
In my example, right-clicking the PickingContent node>add new items gave me the correct list.
And yes, we're probably doing the same tutorial :)

How does the Back button in a web browser work?

I searched the Web about this question but I found nothing:
What is the logic of the back button? What is happening when we hit the back button on a Web browser?
I really would like to understand more about that.
Your web browser keeps a stack (or list, if you will) of the web pages that you have visited in that window. Let's say your home page is search.example and from there you visit a few other websites: video.example, portal.example, and news.example. Upon visiting the last one, the list looks like this:
search.example -> video.example -> portal.example -> news.example
^
|
current page
When you press the Back button, the browser takes you back to the previous page in the list, like this:
search.example -> video.example -> portal.example -> news.example
^
|
current page
At this point you can press Back again to take you to video.example, or you can press Forward to put you at news.example again. Let's say you press Back a second time:
search.example -> video.example -> portal.example -> news.example
^
|
current page
If you now go to, say, example.com, the list changes to look like this:
search.example -> video.example -> example.com
^
|
current page
Note that both portal.example and news.example are gone from the list. This is because you took a new route. The browser only maintains a list the pages you visited to get to where you are now, not a history of every page you've ever been to. The browser also doesn't know anything about the structure of the site you're visiting, which can lead to some surprising behavior.
You're on a shopping site (shop.example, as a short example) that has categories and subcategories of products to browse through. The site designer has thoughtfully provided breadcrumbs near the top of the window to allow you to navigate through the categories. You start at the top page of the site, click on Hardware, then Memory. The list now looks like this:
search.example -> shop.example -> shop.example/hw -> shop.example/hw/mem
^
|
current page
You want to go back to the Hardware category, so you use the breadcrumbs to go up to the parent category instead of using the Back button. Now the browser list looks like this:
search.example -> shop.example -> shop.example/hw -> shop.example/hw/mem -> shop.example/hw
^
|
current page
According to the site structure, you went backward (up a level), but to the browser you went forward because you clicked on a link. Any time you click on a link or type in a URL in the address bar, you are going forward as far as the browser is concerned, whether or not that link takes you to a page that you've already been to.
Finally, you want to return to the main site page (shop.example). You could use the breadcrumbs, but this time you click the Back button -- it seems obvious that it should take you up one level, right? But where does it take you?
It's initially confusing to many users (myself included, when I happen to do exactly this) that it takes you "down" a level, back to the Memory category. Looking at the list of pages, it's easy to see why:
search.example -> shop.example -> shop.example/hw -> shop.example/hw/mem -> shop.example/hw
^
|
current page
To go back to the main page using only the Back button would require two more presses, taking you "back" to the Hardware category and finally to the main page. It seems so obvious to us programmers what's going on, but it surprises the heck out of regular users all the time because they don't realize that the browser doesn't know anything about the hierarchical structure of whatever website they happen to be on.
Would it be great if browsers would let site designers program the Back button to do the obvious thing (take you up a level) rather than whatever it does now?
A commenter asked whether the browser reloads the page or simply displays it out of its local cache.
The answer is it depends. Site designers can specify whether the browser should cache the page or not. For pages that are set as non-cached, the browser reloads the page from the server when you press Back, as though it was the first time you are visiting it. For cached pages, the browser displays it out of the cache, which is much faster.
I like to think of it as re-issuing my last request. If you performed a simple GET, it would probably return the same thing it did last time (minus dynamic content). If you had done a POST, you're going to resubmit the form (after confirmation) to the server.
I think the easiest way to explain this is in pseudocode:
class Page:
String url, ...
Page previous, next # implements a doubly-linked list
class History:
Page current # current page
void back():
if current.previous == null:
return
current = current.previous
refresh()
void forward():
if current.next == null:
return
current = current.next
refresh()
void loadPage(Page newPage):
newPage.previous = current
current.next = newPage # remove all the future pages
current = current.next
display(current)
The basic idea is to return to the last page or logical site division.
Looking at Gmail you'll see if you do a search and click a message then hit the back button it will take you back to the search that you did.
When you click it in most browsers it will either resend the last http request or will load a cache if the browser caches sites.
A history of pages viewed is kept in a stack-like form. When you "pop" the top three pages (A, B, C, for instance) and then go to a different page D, you cannot get to B again by hitting forward.
As a devoloper, you should make sure that your webapp works no matter how the browser handles the Back button :-) Does it resend the request? Is the new request identical to the old one, or does it differ in any way? Will browser ask user to confirm re-POST? What elements of the page will be re-requested and what loaded from cache? Will browser respect my cache-control headers?
Answers to these question depend on make, version of a browser and user settings. Design you software so that all this doesn’t matter that much.
Sorry for not very direct answer, but there are some straight answers here already.
a browser always stored the pages for its remembering and when we press the back button
it doesn't send the request to server for the previous page instead it just see its cache
where it stored the pages and it follow the LIFO rule that is why it give us that page first
on pressing the back button which we opened in the last
There is something I want to add as a complement.
When you hit the back button in your browser, or(alt+left) in chrome, the browser actually just loads the cached HTML file in the history.
it doesn't send another GET request to the server,
so when you go back in some ecommerce website and pass the password again it will throw exception to you.
it's true some web pages do not allow you to cache itself but that's rare, and in that case or the cache has expired, the browser will send the GET request instead of using the HTML from the cache.
The browser loads the last viewed page before the current one, and then follows any redirection that might happen?
I kind of seem to be missing the point of the question.

Resources