Zion
Zion

Reputation: 1610

C# PhantomJS Xpath Issues

code:

using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using OpenQA.Selenium.PhantomJS;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium;

namespace Scrape
{
    class Program
    {
        static void Main(string[] args)
        {

            PhantomJSDriver driver = new PhantomJSDriver();
            driver.Navigate().GoToUrl("http://www.regmovies.com/theatres/theatre-folder/edwards-west-oaks-mall-stadium-14-rpx-9364");
            var nodes = driver.FindElementsByXPath(".//*[@id='content']/div/div/div[2]/div[1]/div/div[2]/div[1]/div/div[1]/h3/a");
            foreach(var node in nodes)
            {
                Console.WriteLine(node.Text);

            }
            Console.Read();

        }
    }
}

the xpath is valid because it returns something on firebug however it doesn't show any text.

whats going on?

however setting the xpath to

var nodes = driver.FindElementsByXPath("//a");

yields the movie names but not the specific xpath. what's going on?

Upvotes: 1

Views: 310

Answers (1)

alecxe
alecxe

Reputation: 474001

Try waiting for the results to appear before getting the show links:

IWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(ExpectedConditions.ElementIsVisible((By.CssSelector("div.results"))));

Upvotes: 1

Related Questions