title: Selenium Unable to Locate HTML elements Except with ID
body: <p>I'm trying to write a python program using selenium and unfortunately I faced a strange problem. I have web-page written in JSP, where I can't access elements with <code>.find_element_by_*</code> commands, except with <code>.find_elements_by_id</code>. None of tags can be located. </p>
  
  <p>If I access some elements with its ID, then I can access to its children by other find commands (e.g. <code>tag_name</code>, <code>name</code>, etc). For example, if I have this HTML:</p>
  
  <pre><code>&lt;div id="myId"&gt;
      &lt;div name="myName"&gt;Test Div&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I can access inner <code>div</code> with <code>.find_element_by_id("myId").find_element_by_name("myName")</code> but I can't access it using <code>.find_element_by_name("myName")</code> and if I use <code>.find_elements_by_tag_name("div")</code> for the whole HTML, I got an empty list.</p>
  
  <p>Actually my web-page is compatible with IE 7, I tried to set parameter version in <code>desired_capabilities</code>, but it didn't help and the web-driver loads with IE 10 as default.</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>Here is the python script that I used:</p>
  
  <pre><code>from selenium import webdriver
  
  def my_method(web_driver = "Firefox"):
      # launch web-driver
      if web_driver.upper() == "IE":
          driver = webdriver.Ie()
          print "IE"
  
      else:
          driver = webdriver.Firefox()
          print "FireFox"
  
      # navigating
      driver.get("http://python.org")
  
      # accessing elements
      ## .find_by_tag_name
      e = driver.find_elements_by_tag_name("html")
      print "number of html tags: " + str(len(e))
  
      e = e[0].find_elements_by_tag_name("a")
      print "number of A tags using html tag: " + str(len(e))
  
      e = driver.find_elements_by_tag_name("a")
      print "number of A tags: " + str(len(e))
  
      e = driver.find_elements_by_tag_name("body")
      print "number of body tags: " + str(len(e))
  
      e = driver.find_elements_by_tag_name("html")
      e = e[0].find_elements_by_tag_name("body")
      print "number of body tags using html tag: " + str(len(e))
  
      ## .find_by_xpath
      e = driver.find_elements_by_xpath("//a")
      print "number of A xpath: " + str(len(e))
  
      e = driver.find_elements_by_xpath("/html/body")
      print "number of body xpath: " + str(len(e))
  
      ## .find_by_class_name
      e = driver.find_elements_by_class_name("reference")
      print "number of A using class name: " + str(len(e))
  
      ## .find_by_css_selector
      e = driver.find_elements_by_css_selector("a[class='reference']")
      print "number of A using css selector: " + str(len(e))
  
      driver.close()
  
  # execute
  my_method(web_driver = "Firefox")
  my_method(web_driver = "Ie") 
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>In the HTML we have to separate parts: a menu and a main page. Each one has an HTML tag and is rendered separately. The result HTML code in both parts is simple and is similar to this:</p>
  
  <pre><code>&lt;html lang="en_us"&gt;
      &lt;body&gt;
          &lt;div id="testdiv"&gt;
          &lt;table align="center" border="0"&gt;
              &lt;tr bgcolor="#666666"&gt;
                  &lt;td&gt;&lt;img src="img.jpg"/&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;div id="message" style="color:white;font-size:12px;font-    weight:bold;"&gt;message&lt;/div&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>If anyone is familiar with JSP, I want to know how JSP tags would be converted to HTML tags, since it can help me to detect the problem about accessing tags.</p>