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 { ...@@ -24,22 +24,22 @@ public class Practice {
SoftAssert test= new SoftAssert(); 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<=6;i++)
for(int i=1;i<=3;i++)
{ String buttonXPath = "(//div[@class='product-action']/button)[" + i + "]"; { String buttonXPath = "(//div[@class='product-action']/button)[" + i + "]";
button = object.until(ExpectedConditions.elementToBeClickable(By.xpath(buttonXPath))); 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) if(i==1)
{ {
int j; int j;
for( j=1;j<=5;j++) for( j=1;j<=5;j++)
{ {
object.until(ExpectedConditions.elementToBeClickable(broklebutton)); incrementButton.click();
broklebutton.click();
} }
test.assertTrue(j==2,"5 items added in cart"); test.assertTrue(j==2,"5 items added in cart");
...@@ -52,9 +52,20 @@ public class Practice { ...@@ -52,9 +52,20 @@ public class Practice {
int j; int j;
for(j=1;j<=7;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)); else if(i==5)
culiFlower.click(); {
int j;
for(j=1;j<=7;j++)
{
incrementButton.click();
} }
test.assertFalse(j>3,"If not meets return false"); test.assertFalse(j>3,"If not meets return false");
...@@ -62,6 +73,14 @@ public class Practice { ...@@ -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(); 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