0

I am using selenium version 2.45 with internet explorer 11 and works well but i have problem in assert function and tr and catch they aren't included!!

so how can i start maybe i did something wrong btw i start with console application and added reference (Selenium WebDriver, Selenium WebDriver Support Classes, WebDriver-backed Selenium, Selenium Remote Control.)

if there is something wrong kindly tell me how can i start from first

-my code open google and search for amazon then open amazon and search for something invalid i want make it return that there is no data find so how can i search for text on page line "did not match" thanks in advance.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Diagnostics;
using System.Collections;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;




class GoogleSuggest
{
    static void Main(string[] args)
    {

        IWebDriver driver = new InternetExplorerDriver();
        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
        driver.Navigate().GoToUrl("http://www.google.com/");
        driver.FindElement(By.Id("lst-ib")).SendKeys("amazon");
        driver.FindElement(By.Id("lst-ib")).SendKeys(Keys.Enter);
        driver.FindElement(By.ClassName("r")).Click();
        driver.FindElement(By.Id("twotabsearchtextbox")).SendKeys("akajerhfbds bvksajhgrcbskhb");
        driver.FindElement(By.Id("twotabsearchtextbox")).SendKeys(Keys.Enter);
        Thread.Sleep(6000);
        driver.Quit();

    }
}
ahmed Bahgat
  • 61
  • 1
  • 1

1 Answers1

0

I did a search on Amazon for "asdvasdv" - inspecting the elements, there is one with an id of "noResultsTitle" - if Amazon is consist with this you can use

FindElement(By.CssSelector("[id*='noResults']"))
Mike Weber
  • 311
  • 2
  • 16
  • thanks to you ,but i cannot search for text page ? i had to try open www.w3school.com and open Learn SQL then Press " Next Chapter> " it couldnot find it whatever xpath or linktext even is there alternative solution ? – ahmed Bahgat Jun 01 '15 at 23:17
  • If you want to find using specific text, I believe an xpath can be used. Does it need to be text specific? This has more info on xpath - http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more – Mike Weber Jun 01 '15 at 23:36