Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't see the HTML in the element
    primarykey
    data
    text
    <p>I am able to log on and access my account page, here is a sample of the HTML (modified for brevity and to not exceed the URL limit):</p> <pre><code> &lt;div class='table m_t_4'&gt; &lt;table class='data' border=0 width=100% cellpadding=0 cellspacing=0&gt; &lt;tr class='title'&gt; &lt;td align='center' width='15'&gt;&lt;a&gt;&lt;/a&gt;&lt;/td&gt; &lt;td align='center' width='60'&gt;&lt;/td&gt; &lt;/tr&gt; &lt;TR bgcolor=&gt; &lt;td valign='top' align='center'&gt;1&lt;/TD&gt; &lt;td valign='top' align='left'&gt;&lt;img src='/images/sale_small.png' alt='bogo sale' /&gt;Garden Escape Planters&lt;/TD&gt; &lt;td valign='top' align='right'&gt;13225&lt;/TD&gt; &lt;td valign='top' align='center'&gt;2012-01-17 11:34:32&lt;/TD&gt; &lt;td valign='top' align='center'&gt;FILLED&lt;/TD&gt; &lt;td valign='top' align='center'&gt;&lt;A HREF='https://www.daz3d.com/i/account/orderdetail?order=7886745'&gt;7886745&lt;/A&gt;&lt;/TD&gt; &lt;td valign='top' align='center'&gt;&lt;A HREF='https://www.daz3d.com/i/account/req_dlreset?oi=18087292'&gt;Reset&lt;/A&gt; &lt;/TR&gt; </code></pre> <p>Note that the only item I really need is the first HREF with the "order=7886745'>7886745&lt;"... </p> <p>And there are several of the TR blocks that I need to read. </p> <p>I am using the following xpath coding:</p> <pre><code> browser.get('https://www.daz3d.com/i/account/orderitem_hist?') account_history = browser.find_element_by_xpath("//div[@class='table m_t_4']"); print account_history product_block = account_history.find_element_by_xpath("//TR[contains(@bgcolor, '')]"); print product_block product_link = product_block.find_element_by_xpath("//TR/td/A@HREF") print product_link </code></pre> <p>I am using the Python FireFox version of webdriver.</p> <p>When I run this, the account_history and product_block xpath's seem to work fine (they print as "none" so I assume they worked), but I get a "the expession is not a legal expression" error on the product_link.</p> <p>I have 2 questions:</p> <p>1: Why doesn't the "//TR/td/A@HREF" xpath work? It is supposed to be using the product_block - which it (should be) just the TR segment, so it should start with the TR, then look for the first td that has the HREF...correct?</p> <p>I tried using the exact case used in the HTML, but I think it shouldn't matter...</p> <p>2: What coding do I need to use to see the content (HTML/text) of the elements? </p> <p>I need to be able to do this to get the URL I need for the next page to call. </p> <p>I would also like to see for sure that the correct HTML is being read here...that should be a normal part of debugging, IMHO. </p> <p>How is the element data stored? Is it in an array or table that I can read using Python? It has to be available somewhere, in order to be of any use in testing - doesn't it?</p> <p>I apologize for being so confused, but I see a lot of info on this on the web, and yet much of it either doesn't do anything, or it causes an error. </p> <p>There do not seem to be any "standard" coding rules available...and so I am a bit desperate here...</p> <p>I really like what I have seen in Selenium up to this point, but I need to get past it in order to make this work!</p> <p>Edited!</p> <p>OK, after getting some sleep the first answer provided the clue - find_elements_by_xpath creates a list...so I used that to find all of the xpath("//a[contains(@href,'https://www.daz3d.com/i/account/orderdetail?order=')]"); elements in the entire history, then accessed the list it created...and write it to a file to be sure of what I was seeing.</p> <p>The revised code:</p> <pre><code> links = open("listlinks.txt", "w") browser.get('https://www.daz3d.com/i/account/orderitem_hist?') account_history = browser.find_element_by_xpath("//div[@class='table m_t_4']"); print account_history.get_attribute("div") product_links = [] product_links = account_history.find_elements_by_xpath("//a[contains(@href,'https://www.daz3d.com/i/account/orderdetail?order=')]"); print str(len(product_links)) + ' elements' for index, item in enumerate(product_links): link = item.get_attribute("href") links.write(str(index) + '\t' + str(link) + '\n') </code></pre> <p>And this gives me the file with the links I need...</p> <pre><code> 0 https://www.daz3d.com/i/account/orderdetail?order=7905687 1 https://www.daz3d.com/i/account/orderdetail?order=7886745 2 https://www.daz3d.com/i/account/orderdetail?order=7854456 3 https://www.daz3d.com/i/account/orderdetail?order=7812189 </code></pre> <p>So simple I couldn't see it for tripping over it...</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload