Skip to content

Updates to AXAPI implementation: Do not throw error in init, and poll for correct URL#13

Merged
spectranaut merged 4 commits intoacacia-test-testdriverfrom
updates-to-axapi-imp
Jul 30, 2024
Merged

Updates to AXAPI implementation: Do not throw error in init, and poll for correct URL#13
spectranaut merged 4 commits intoacacia-test-testdriverfrom
updates-to-axapi-imp

Conversation

@spectranaut
Copy link
Copy Markdown
Collaborator

No description provided.

@spectranaut spectranaut requested a review from alice July 25, 2024 20:02
stack = [browser]
return tab

def find_tab(root, product, url):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is product used?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (str(tab_url) == url):
if err:
continue
if str(tab_url) == url:

Also, why do we need to use str() here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you for explaining! Maybe add a comment as well?

Also, did you want to explicitly handle err, and remove the extra parentheses?

@spectranaut spectranaut force-pushed the updates-to-axapi-imp branch from 002bfb3 to 3c11dc5 Compare July 29, 2024 21:25
if role == "AXWebArea":
return node
(err, tab_url) = AXUIElementCopyAttributeValue(node, "AXURL", None)
if (str(tab_url) == url):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you for explaining! Maybe add a comment as well?

Also, did you want to explicitly handle err, and remove the extra parentheses?

@spectranaut spectranaut merged commit 6417c83 into acacia-test-testdriver Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants