Updates to AXAPI implementation: Do not throw error in init, and poll for correct URL#13
Conversation
| stack = [browser] | ||
| return tab | ||
|
|
||
| def find_tab(root, product, url): |
There was a problem hiding this comment.
whoops, that was left in because we need the product for the differences in chrome and firefox on linux. I'll remove.
| if role == "AXWebArea": | ||
| return node | ||
| (err, tab_url) = AXUIElementCopyAttributeValue(node, "AXURL", None) | ||
| if (str(tab_url) == url): |
There was a problem hiding this comment.
| if (str(tab_url) == url): | |
| if err: | |
| continue | |
| if str(tab_url) == url: |
Also, why do we need to use str() here?
There was a problem hiding this comment.
Very good question. It turns out that AXUIElementCopyAttributeValue(node, "AXURL", None) returns a object, a <objective-c class NSURL at 0x1d...>, so you can't compare it to a URL string, you need to convert it first! Really confused me at first, because if you print tab_url, it looks like a string.
There was a problem hiding this comment.
Ah, thank you for explaining! Maybe add a comment as well?
Also, did you want to explicitly handle err, and remove the extra parentheses?
002bfb3 to
3c11dc5
Compare
| if role == "AXWebArea": | ||
| return node | ||
| (err, tab_url) = AXUIElementCopyAttributeValue(node, "AXURL", None) | ||
| if (str(tab_url) == url): |
There was a problem hiding this comment.
Ah, thank you for explaining! Maybe add a comment as well?
Also, did you want to explicitly handle err, and remove the extra parentheses?
No description provided.