Skip to content

Instantly share code, notes, and snippets.

@erajanraja24
Last active July 29, 2017 06:20
Show Gist options
  • Save erajanraja24/a202140136cb5b1269353aa16bce7e47 to your computer and use it in GitHub Desktop.
Save erajanraja24/a202140136cb5b1269353aa16bce7e47 to your computer and use it in GitHub Desktop.
I Live SG Automation script
package com.test.on;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import come.ExcelReadWrite.ExcelRead;
public class IliveSG extends Wrapper{
static int lrow;
public static void iLiveSGScript() throws Exception {
lrow=ExcelRead.getLastRow("Sheet1", "Upload_Sequence.xlsx");
login();
sleep(4500);
clickPostMyPlace();
for(int i=1;i<=lrow;i++)
{
formFilling(i);
sleep(7000);
submit();
navigateTo("https://www.ilivesg.com/new-listing");
}
}
public static void login() throws Exception
{
launchBrowser("Chrome");
navigateTo("https://www.ilivesg.com");
maximizeTheBrowserWindow();
driver.findElement(By.id("menu-435-2")).click();
//Login
enterTextInTextbox("id", "edit-name", ExcelRead.username());
enterTextInTextbox("id", "edit-pass", ExcelRead.password());
click("id","edit-submit");
}
public static void clickPostMyPlace() throws Exception
{
//Click on the Post My Place
try
{
click("id","menu-903-2");
}
catch (Exception e) {
sleep(4000);
click("id","menu-903-2");
e.printStackTrace();
}
}
public static void formFilling(int i) throws Exception
{
//Click on the Whole Unit
selectRadioButton("id","edit-field-room-und-0-rent-type-2");
if(ExcelRead.getvalue(2, i, "Sheet1", "Upload_Sequence.xlsx")=="")
{
selectRadioButton("id","edit-field-room-und-0-ptype-c");
}
else
{
//click the or HDB
selectRadioButton("id","edit-field-room-und-0-ptype-h");
}
//Select the Location
click("className","ui-multiselect");
click("className","ui-multiselect-filter");
sleep(2000);
//selectTextFromLiDropDown("className","ui-multiselect-checkboxes",ExcelRead.getvalue(13, i, "Sheet1", "Upload_Sequence.xlsx"));
sendText(ExcelRead.getvalue(13, i, "Sheet1", "Upload_Sequence.xlsx"));
pressDown();
pressEnter();
sleep(2500);
//Select Bed
Wrapper.selectvalueFromNormalDropDown("id", "lst-bedroom",ExcelRead.getvalue(7, i, "Sheet1", "Upload_Sequence.xlsx"));
//Wrapper.selectvalueFromNormalDropDown("id", "lst-bedroom","Changi");
//Enter Monthly Rent
enterTextInTextbox("id","edit-field-room-und-0-price",ExcelRead.getvalue(6, i, "Sheet1", "Upload_Sequence.xlsx"));
//Enter Description
enterTextInTextbox("id","edit-field-room-und-0-desc",ExcelRead.getvalue(11, i, "Sheet1", "Upload_Sequence.xlsx"));
//Enter Street Name
Wrapper.enterTextInTextbox("id", "edit-field-rm-add-und-0-thoroughfare", ExcelRead.getvalue(1, i, "Sheet1", "Upload_Sequence.xlsx")+" "+ExcelRead.getvalue(2, i, "Sheet1", "Upload_Sequence.xlsx"));
//pressDown();
//pressEnter();
//Enter text in Postal code
Wrapper.enterTextInTextbox("id", "edit-field-rm-add-und-0-postal-code", ExcelRead.getvalue(3, i, "Sheet1", "Upload_Sequence.xlsx"));
//Auto Repost
selectTextFromNormalDropDown("id","lst-auto_repost_opt","For 60 Days");
//Upload File
pageDown();
uploadFile("id","edit-field-rm-img-und-0-filefield-plupload-pud_browse",ExcelRead.getvalue(17, i, "Sheet1", "Upload_Sequence.xlsx"));
sleep(8500);
//click("id","edit-save-edit-publish");
}
public static void submit() throws Exception
{
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("field_rm_img[und][0][title]")));
//click("id","edit-save-edit-publish");
pageDown();
sleep(3000);
//driver.findElement(By.id("edit-save-edit-publish")).submit();
click("xpath","//input[@id='edit-save-edit-publish']");
//driver.findElement(By.xpath("//input[@id='edit-save-edit-publish']")).click();
sleep(5000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment