Guys, how can I run javascript code inside a Selenium browser and extract its results? I want to be as if I opened the Firefox browser, typed that command inside the web inspector console log and got the results. I don't want to have to deal with url.request because it doesn't load javascript changes.
@Arrow Selenium is designed to test user interaction with web pages. I don't know of any way to have Selenium run JavaScript. Besides, there are better tools to test your JavaScript directly, such as Jest.
@Arrow It will help if you back up a step. What is the exact use case which you are trying to test?
@cᴏʟᴅsᴘᴇᴇᴅ wow, I didn't realize you have a hammer
Good luck. It's a rocky road to gold. Especially since most of the questions in these high traffic tags are pretty pedestrian, and there's no real satisfaction in answering most of them.
These days I hang around the data science tags more, since the questions there are generally more challenging. But there's not much of a community there, so votes on Qs/As are far and few.
That's probably also why people on chats have stopped complaining about the things I do, because I'm out of their line of sight :p
I've answered a few Numpy questions, and I'm about halfway to bronze, but I'm still very much a beginner in Numpy. I really should get around to working my way through a tutorial rather than randomly reading doc pages and SO answers...
Now someone will post a brilliant answer that works bottom-up rather than top-down... I suppose such an algorithm exists, but I couldn't come up with one (although I'm certainly no Dynamic Programming expert), and I've already spent too many hours working on that answer.
@IljaEverilä I don't know SQLalchemy, but from the comments it sounds like it was a "typo / problem that cannot be reproduced", and it should be closed as such rather than getting a full answer. But if you think this sort of mistake is a common beginner's error, and that other SQLalchemy with a similar problem might be able to find this question with a simple Google search, then you could write a proper answer if you want to.
for idx , value in enumerate(abc): if(idx%2 == 0): start = value else: end = value tdelta = datetime.strptime(end, FMT) - datetime.strptime(start, FMT) time_interval.append(tdelta)
for idx , value in enumerate(abc):
if(idx%2 == 0):
start = value
else:
end = value
tdelta = datetime.strptime(end, FMT) - datetime.strptime(start, FMT)
time_interval.append(tdelta)
Error output as follows :
Traceback (most recent call last): File "podTimeINtervalAnalyzer.py", line 38, in <module> tdelta = datetime.strptime(end, FMT) - datetime.strptime(start, FMT) NameError: name 'end' is not defined
@deepak There are a couple of ways to get multiple items when iterating. You could use an index, or you could zip two iterables together.
>>> s = 'abcdef'; [u+v for u, v in zip(s, s[1:])]
['ab', 'bc', 'cd', 'de', 'ef']
>>> s = 'abcdef'; it = iter(s); [u+v for u, v in zip(it, it)]
['ab', 'cd', 'ef']
Although it pains me to defend Zed, it does make the code more self-documenting to do words = sentence.split(' '); return words rather than return sentence.split(' ')
Of course, a seasoned Python coder probably wouldn't bother making it 2 lines in such a simple case, but it's probably a good idea for newbies. We often get people doing stuff like for word in sentence:, doing some processing on the "words" and then getting confused when the output isn't what they expect.
27 lines is a bit too much to post directly in chat, it'd be better to use a paste service instead and just drop us a link to it. Also, you may want to check out Code Review
@Keepthesemind In case Rawing's advice wasn't totally clear, we're happy to give you feedback, but we prefer that code posted directly into Chat is fairly short, no more than a dozen lines or so.
This is my first attempt at Python. I started with some code from https://github.com/peliot/XIRR-and-XNPV and tried to 'improve' on it. But I would like to know if in these few lines I already made beginner's mistakes. I'm particularly interested to learn whether there is a more elegant way to ha...
@Keepthesemind We also have a rule about not posting your fresh questions here, although that's mainly aimed at SO questions. But I'll briefly note that you should use named Exceptions, rather than using bare except. And you could do with a blank line between your functions, and after the import section. I can't say much else about that code because I don't know what xnpv is and I don't use scipy
@ravenfrost Well, it's generally not a good idea to put mutable objects into a set. It's possible, as long as the mutation doesn't affect the object's hash, but it's a recipe for chaos & confusion, IMHO.
I can't believe this guy! I told him that eval was the cause of his problem, that it's not necessary in his code, and that it can be dangerous. So what does he do? Adds moreeval calls! :facepalm: stackoverflow.com/questions/47003093/…
I have been practicing logging into websites using requests, and for the most part I have been successful. I am currently trying to log into starbucks.com/account/signin but I can not seem to figure it out. I know that there are additional parameters to send (rememberMe, sso, reputation) and I also set the X-NewRelic-ID in the header. Not sure what else I am missing and what makes this website different from others? Any insight would be much appreciated. Thank you!
@antfuentes87 Well, I would always try to almost mirror the normal request that is sent to the backend when you manually do the signin via the browser. This is easy enough to log via inspect tools. You can see the complete request with the headers and thus can mirror it and hopefully get expected output
Hey guys, I managed to create a MCVE of my problem.
class E:
def __init__(self):
self.mark=False
def __hash__(self):
return id(self)
class E_Container:
def __init__(self):
self.myset={E() for _ in range(10)}
def mark(self, e):
if e in self.myset:
if not e.mark:
e.mark=True
fromContainer = E_Container()
toContainer = E_Container()
for e in fromContainer.myset:
toContainer.mark(e)
for e in toContainer.myset:
print(e.mark)
How can I make it so that I get E's from the fromContainer and find the match in toContainer and mark that one instead of the one in fromContainer?
if i have a matrix that i want to multiply by another in python, and that matrix has e^i phi in it, where phi isn't a number, but a variable dependent on the experiment being performed, how can i get python to not "do" anything with it?
so for some reason the if check is not working. I currently have ` if 'ThePeskyWabbit' != data.getName() or 'CredibilityBot' != data.getName():` but it executes even on those two list items