-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmagicBricks4.java
More file actions
99 lines (69 loc) · 3.4 KB
/
magicBricks4.java
File metadata and controls
99 lines (69 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.lang.String;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import jxl.Workbook;
import jxl.write.DateTime;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
import org.openqa.selenium.JavascriptExecutor;
//test commit
public class magicBricks4 {
//private static final String String = null;
public static void main(String[] args) throws IOException, RowsExceededException, WriteException, InterruptedException {
WebDriver driver = new FirefoxDriver();
// url address of site
driver.get("http://www.magicbricks.com/property-for-sale/residential-real-estate?proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&Locality=Andheri-West&searchLocType=&searchTransMode=&searchLocTime=&cityName=Mumbai&BudgetMin=1-Crores&BudgetMax=2-Crores&searchLocType=&searchTransMode=&searchLocTime=&price=Y&pageOption=");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
JavascriptExecutor javascript = (JavascriptExecutor) driver;
for(int j=1;j<1000;j++)
{
javascript.executeScript("window.scrollTo(0, document.body.scrollHeight);");
// Thread.sleep(500);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
// Extract all basket and list
List<WebElement> baskets = new ArrayList<WebElement>();
baskets.addAll(driver.findElements(By.xpath("//*[starts-with(@id,'priceProperty')]")));
System.out.println(baskets.size());
List<WebElement> room = new ArrayList<WebElement>();
room.addAll(driver.findElements(By.xpath("//*[starts-with(@id,'resultBlockWrapper')]")));
System.out.println(room.size());
File fExcel = new File ("C:\\Users\\SID\\Desktop\\selenium test\\room.xls");
WritableWorkbook writableBook = Workbook.createWorkbook(fExcel);
writableBook.createSheet("Data",0);
WritableSheet writableSheet = writableBook.getSheet(0);
List<WebElement> all = new ArrayList<WebElement>();
// List<WebElement> tds = new ArrayList<WebElement>();
all = driver.findElements(By.xpath("//*[@id='srpColumnsConWrap']"));
List<WebElement> allDivs = driver.findElements(By.xpath("//*[starts-with(@id,'resultBlockWrapper')]"));
for(int i=0;i<room.size(); i++){
System.out.println("***************************");
System.out.println(baskets.get(i).getText()); // prints all the block data
// String tds = ((WebElement) room.get(i).findElements(By.className("proDetailsRowElm"))).getText();
// System.out.println(tds);
// System.out.println(((WebDriver) room).findElements(By.xpath('./div[5]/div[1]/ul/li[3]/div/div[1]/div')));
System.out.println(room.get(i).getText());
// System.out.println(all.get(i).getText());
System.out.println("***************************");
// label = baskets.get(i).getText();
// date = room.get(i).getText();
Label label1 = new Label(0, i, baskets.get(i).getText());
// Label date = new Label(1, i,baskets.get(i).getText());
writableSheet.addCell(label1);
}
// System.out.println(baskets);
writableBook.write();
writableBook.close();
}
}