Selenium, Python. Gives no such element: Unable to locate element error whether the button is there
<p>I am working on my test case which includes sending values to the input fields for buying tickets. But for this case selenium gives me unable to locate element error while I am trying to locate input field named itemq_3728, the problem is the page is changing the name of input field every time it reopens the page.</p>

<p>How can I locate the input field ?
 I try the XPath but can't achieve the goal and also couldn't write it relative to the name of the ticket</p>

<pre><code>&lt;table id="bms_tickets" width="90%" cellspacing="5" cellpadding="0" class="bms_tickets table"&gt;
            &lt;thead&gt;
                &lt;tr&gt;
                    &lt;th&gt;NAME&lt;/th&gt;
                    &lt;th width="240px"&gt;PRICE&lt;/th&gt;

                    &lt;th width="100px"&gt;QUANTITY&lt;/th&gt;

                &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody id="resTypesTable"&gt;


&lt;tr id="bms_restype_3728" class="bms_restype"&gt;
&lt;td class="bms_restype_desc"&gt;
    Gen Ad


    &lt;div style="font-size:10px;margin-left:5px;"&gt;

    &lt;/div&gt;
&lt;/td&gt;                       
&lt;td class="bms_restype_price"&gt;


            $10.00
            &lt;input type="hidden" name="pay_itemq_3728" value="10.00"&gt;   



&lt;/td&gt;

&lt;td class="bms_restype_qty"&gt;    

                &lt;input type="text" name="itemq_3728" value="0" placeholder="1" min="1"&gt;
&lt;/td&gt;

&lt;/tr&gt;
            &lt;/tbody&gt;
            &lt;/table&gt;
</code></pre>

<p>You can locate it using <code>cssSelector</code> as below :-</p>

<pre><code>driver.find_element_by_css_selector("td.bms_restype_qty &gt; input[type='text']")
</code></pre>

<p>Or if you're interested to locate this element using <code>xpath</code> you can locate it wrt <code>Gen Ad</code> name column text as below :-</p>

<pre><code>driver.find_element_by_xpath(".//td[normalize-space(.)='Gen Ad' and @class = 'bms_restype_desc']/following-sibling::td[@class='bms_restype_qty']/input")
</code></pre>

<p>Or</p>

<pre><code>driver.find_element_by_xpath(".//tr[td[normalize-space(.)='Gen Ad']]/td[@class='bms_restype_qty']/input")
</code></pre>

python google-chrome selenium xpath