Red Bus
Red Bus
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
driver.get("https://www.redbus.in/");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id='src']")).sendKeys("Mumbai");
driver.findElement(By.xpath("//li[@data-id='462']")).click();
driver.findElement(By.xpath("//*[@id='dest']")).sendKeys("Pune");
driver.findElement(By.xpath("//li[@data-id='130']")).click();
driver.findElement(By.xpath(".//*[@id='onward_cal"
+ "']")).click();
driver.findElement(By.xpath("//td[text()='7']")).click();
driver.findElement(By.xpath("//button[@id='search_btn']")).click();
driver.findElement(By.xpath("//label[@for='dtAfter 6 pm']")).click();
driver.findElement(By.xpath("//div[@class='close'] ")).click();
driver.findElement(By.xpath("//label[@for='bt_SLEEPER']")).click();
driver.findElement(By.xpath("//*[@id=\"root\"]/div/div[3]/div[2]
")).click();
driver.findElement(By.xpath("//*[@id=\"19000009\"]/div/div[2]/div[1]")).click();
driver.findElement(By.xpath("//*[@id=\"rt_19000009\"]/div/div/div/
div[3]/div[2]/div[2]/canvas")).click();
driver.findElement(By.xpath("//*[@id=\"19000009\"]/div[2]/div[2]/div[2]/div[2]/
div/div/div[2]/div/div/div[2]/div[1]/div/div[1]/div/ul/li[2]/div[1]/div")).click();
driver.findElement(By.xpath("//button[text()='Proceed to
book']")).click();
driver.findElement(By.xpath("//canvas[@data-type='lower']")).click();
driver.findElement(By.xpath(".//*[@id='txtReturnCalendar']")).click();
driver.findElement(By.xpath(".//*[@id='rbcal_txtReturnCalendar']/table[2]/tbody/
tr[5]/td[4]")).click();
driver.findElement(By.xpath(".//*[@id='searchBtn']")).click();
Thread.sleep(12000);
String busName="";
String busPrice="";
busName=result.findElement(By.className("BusName")).getText();
busPrice=result.findElement(By.className("fareSpan")).getText();
System.out.println("Price for " + busName + " is: " +busPrice);
driver.close();