Commit 16a1ab58 authored by Qazi Zain's avatar Qazi Zain

click button is updated and generic

parent 84875cf7
......@@ -24,22 +24,22 @@ public class Practice {
SoftAssert test= new SoftAssert();
WebElement broklebutton= obj.findElement(By.xpath("//div[@class='products-wrapper']/div/div/h4[text()='Brocolli - 1 Kg']/following-sibling::div[@class='stepper-input']/a[@class='increment'][1]"));
WebElement incrementButton;
WebElement culiFlower = obj.findElement(By.xpath("//div[@class='products-wrapper']/div/div/h4[text()='Cauliflower - 1 Kg']/following-sibling::div[@class='stepper-input']/a[@class='increment'][1]"));
for(int i=1;i<=3;i++)
for(int i=1;i<=6;i++)
{ String buttonXPath = "(//div[@class='product-action']/button)[" + i + "]";
button = object.until(ExpectedConditions.elementToBeClickable(By.xpath(buttonXPath)));
String incrementXpath = "(//a[@class='increment'])["+i+"]";
incrementButton= object.until(ExpectedConditions.elementToBeClickable(By.xpath(incrementXpath)));
if(i==1)
{
int j;
for( j=1;j<=5;j++)
{
object.until(ExpectedConditions.elementToBeClickable(broklebutton));
broklebutton.click();
incrementButton.click();
}
test.assertTrue(j==2,"5 items added in cart");
......@@ -52,9 +52,20 @@ public class Practice {
int j;
for(j=1;j<=7;j++)
{
incrementButton.click();
}
test.assertFalse(j>3,"If not meets return false");
button.click();
}
object.until(ExpectedConditions.elementToBeClickable(culiFlower));
culiFlower.click();
else if(i==5)
{
int j;
for(j=1;j<=7;j++)
{
incrementButton.click();
}
test.assertFalse(j>3,"If not meets return false");
......@@ -62,6 +73,14 @@ public class Practice {
}
}
WebElement cart = obj.findElement(By.xpath("//div[@class='cart']/a/img"));
obj.manage().window().maximize();
object.until(ExpectedConditions.elementToBeClickable(cart));
cart.click();
test.assertAll();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment