-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#938 #939 test order page remove goal #943
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some possible logic issues
try: | ||
# use short_wait to avoid long pauses in case of the empty cart | ||
positions_count = len(self.driver.short_wait.until( | ||
self.condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be formatted in one string
yield | ||
self.driver.wait.until(are_changed) | ||
|
||
def first(self) -> elements.Product: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elements.Product
is not clear returning type. Seems we can't set type here without generic types lang feature
|
||
def quantity(self): | ||
return self.driver.short_wait.until(EC.visibility_of_element_located( | ||
(By.XPATH, f'{self.xpath}div[4]/div[2]/input') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems it would be more good to add some class with templates.
We can prefix such classes as se-quantity
or selenium-quantity
. Like we do it with js-
prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most cases xpath
query optimization will be enough
(By.XPATH, f'{self.xpath}div[4]/div[2]/input') | |
(By.XPATH, f'{self.xpath}//input') |
def set(self, quantity: int): | ||
raise NotImplementedError | ||
|
||
def increase(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe step is required (and for decrease
method below too)
def increase(self): | |
def increase(self, step=1): |
Up to you
@@ -100,6 +99,53 @@ def get_goals(self) -> selenium.Goals: | |||
goals.fetch() | |||
return goals | |||
|
|||
def assert_add(self, product: Product, goal_position: int): # Ignore CPDBear | |||
reached_goals = self.get_goals() | |||
self.assertTrue(reached_goals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's object, it'll always return True. You should implement some reached_goals.not_empty()
method
Checked iter if it affects on bool(MyClass())
result. Seems it's not:
In [11]: class A:
...: def __iter__(self):
...: for i in range(10):
...: yield i
...:
In [12]: bool(A())
Out[12]: True
In [13]: class B:
...: def __iter__(self):
...: pass
...:
In [14]: bool(B())
Out[14]: True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will implement __bool__
for the class
reached = reached_goals[goal_position] | ||
|
||
self.assertIn('add', reached) | ||
self.assertEqual(reached['currencyCode'], 'RUB') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems we should improve Goals class interface. All this dict fields is some Jedi knowledge.
Update related #940 task with the comment
reached_detail = reached['add'] # Ignore CPDBear | ||
self.assertEqual( | ||
len(reached_detail['products']), | ||
1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you assume that reached goal will be only one, right?
What if we'll use the method like this?
self.assert_add(product, 0)
self.assert_add(product, 1)
The same is for remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reached_detail['products']
will have length greater 1 only in case if we will add/remove several products to the cart at the same time
It is possible only with clearing the cart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix it in the next issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at the same time
@artemiy312 , y, my code example was exactly about adding at the same time. Our you mean something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@duker33 Yes, I meant at the same moment.
Adding/Removing products with individual clicks publishes separate reached goals with length of products
field =1
To get length of goal's products
field >1 we need to add/remove several different products in one click. Right now the only way to do it is clearing a fulfilled cart.
Closes #938
Closes #939