Reputation: 313
In the following example, I have to click only for Jet Airways. It appears that the xpath selected is correct since it gives the right only from the selection. https://i.sstatic.net/n7s3v.png
However when this same is being pulled by Selenium WebDriver, it says element not visible. But it still gives a Button with zero length text string. as given in watch window.
https://i.sstatic.net/sVZhk.png
I would appreciate if anyone can help me to point if any error I am making since I am new to VBA
Upvotes: 1
Views: 2060
Reputation: 388
Not sure if your XPath is correct and is locating the right static element...
You may use this for locating 'Jet Airways'
//label[text()[contains(.,'Jet Airways')]]
Also, using .click()
, try clicking on the 'Airlines' dropdown before locating the 'Airlines Dropdown' XPath
//span[@title='Airlines']
public class SkyScanner
{
static String chkBxXpth = "//label[@class='dropdown-item cfx']/input[@checked]";
public static void main(String[] args) throws InterruptedException
{
WebDriver driver = new FirefoxDriver();
Actions actions = new Actions(driver);
WebDriverWait wait = new WebDriverWait(driver, 30);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.get("http://skyscanner.cntraveller.com/en-GB/flights#/result?originplace=AUH&destinationplace=LHR");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@title='Airlines']")));
driver.findElement(By.xpath("//span[@title='Airlines']")).click();
List<WebElement> chkBx = driver.findElements(By.xpath(chkBxXpth));
for(WebElement i : chkBx)
{
actions.moveToElement(i).click().perform();
}
driver.findElement(By.xpath("//label[text()[contains(.,'Jet Airways')]]")).click();
}
}
Upvotes: 1