Skip to content

Instantly share code, notes, and snippets.

@erajanraja24
Created August 17, 2017 11:16
Show Gist options
  • Save erajanraja24/2cc6b44c25a348999f7569531fba89af to your computer and use it in GitHub Desktop.
Save erajanraja24/2cc6b44c25a348999f7569531fba89af to your computer and use it in GitHub Desktop.
FlatHub
import java.io.IOException;
import com.addInfo.PostalCode;
import come.ExcelReadWrite.ExcelRead;
import come.ExcelReadWrite.ExcelWrite;
public class Flathub extends Wrapper
{
static int mrow ;
public static void flathubScript() throws IOException
{
login();
addpost();
}
public static void login() throws IOException
{
launchBrowser("Chrome");
navigateTo("https://www.flathub.com/singapore");
maximizeTheBrowserWindow();
sleep(3000);
elementPresent("xpath","(//a[@class='btn btn-link'][@href='/singapore/login'])");
click("xpath","(//a[@class='btn btn-link'][@href='/singapore/login'])");
enterTextInTextbox("id","email",ExcelRead.username());
enterTextInTextbox("id","password",ExcelRead.password());
click("xpath","//button[@type='submit']");
click("xpath","(//a[@href='/singapore/rent/add'])");
}
public static void addpost() throws IOException
{
mrow = ExcelRead.getLastRow("Sheet1", "Upload_Sequence.xlsx");
for(int i=1;i<mrow;i++)
{
if(ExcelRead.getvalue(20, i, "Sheet1", "Upload_Sequence.xlsx").equalsIgnoreCase("Processed")==false)
{
formfilling(i);
sleep(3000);
ExcelWrite.setvalue(20, i, "Sheet1", "Upload_Sequence.xlsx", "Processed");
navigateTo("https://www.flathub.com/singapore/rent/add");
sleep(3000);
}
}
}
public static void formfilling(int i) throws IOException
{
enterTextInTextbox("xpath","//input[@id='title']",ExcelRead.getvalue(12,i,"Sheet1", "Upload_Sequence.xlsx"));
enterTextInTextbox("xpath","//textarea[@id='description']",ExcelRead.getvalue(11,i,"Sheet1", "Upload_Sequence.xlsx"));
System.out.println(convertToFirstUpperCase(ExcelRead.getvalue(13,i,"Sheet1", "Upload_Sequence.xlsx").toLowerCase())+" MRT Station");
selectTextFromNormalDropDown("xpath","//select[@id='nearest-point']",convertToFirstUpperCase(ExcelRead.getvalue(13,i,"Sheet1", "Upload_Sequence.xlsx").toLowerCase())+" MRT Station");
selectTextFromNormalDropDown("xpath","//select[@id='nearest-area']",PostalCode.getPostalCodeRegion(ExcelRead.getvalue(3,i,"Sheet1", "Upload_Sequence.xlsx").substring(0, 2)));
enterTextInTextbox("xpath","//input[@id='address']",ExcelRead.getvalue(4,i,"Sheet1", "Upload_Sequence.xlsx")+ExcelRead.getvalue(5,i,"Sheet1", "Upload_Sequence.xlsx"));
enterTextInTextbox("xpath","//input[@id='postal']",ExcelRead.getvalue(3,i,"Sheet1", "Upload_Sequence.xlsx"));
enterTextInTextbox("xpath","//input[@id='price']",ExcelRead.getvalue(6,i,"Sheet1", "Upload_Sequence.xlsx"));
click("xpath","//div[@class='btn-group']/label");
click("xpath","(//label[@class='btn btn-primary '])[3]");
click("xpath","(//div[6][@class='btn-group']//label[1])");
enterTextInTextbox("xpath","//input[@name='bedroom']",ExcelRead.getvalue(7,i,"Sheet1", "Upload_Sequence.xlsx"));
enterTextInTextbox("xpath","//input[@name='bathroom']",ExcelRead.getvalue(8,i,"Sheet1", "Upload_Sequence.xlsx"));
double size=Double.parseDouble(ExcelRead.getvalue(5,i,"Sheet1", "Upload_Sequence.xlsx"))*10.764;
enterTextInTextbox("xpath","//input[@name='floorsize']",String.valueOf(size));
click("xpath","//div[9][@class='btn-group']//label[1]");
click("xpath","//div[9][@class='btn-group']//label[1]");
pageDown();
uploadFile("xpath","//input[@id='fileupload']",ExcelRead.getvalue(17, i, "Sheet1", "Upload_Sequence.xlsx"));
sleep(8500);
uploadFile("xpath","//input[@id='fileupload']",ExcelRead.getvalue(18, i, "Sheet1", "Upload_Sequence.xlsx"));
sleep(8500);
uploadFile("xpath","//input[@id='fileupload']",ExcelRead.getvalue(19, i, "Sheet1", "Upload_Sequence.xlsx"));
sleep(8500);
click("xpath","//button[@type='submit']");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment