Unable to locate element (hidden textbox) using selenium in python

After passing the value in the NID textbox, new elements are displayed on the web page. such as Firstname :

for row in rows:
    y = driver.find_element_by_id('NId')
    y.send_keys(row)
    driver.find_element_by_xpath("//body").click()
    
    a1 = driver.find_element_by_id('Firstname')
    firstname = a1.get_attribute('value')

After executing the command to set a1, I get an error:

Exception has occurred: NoSuchElementException Message: no such element: Unable to locate element: {“method”:”css selector”,”selector”:”[id=”Firstname”]”}

Textbox NId :

<input class="form-control ltr left text-box single-line" data-val="true" data-val-regex="It is 10 numbers" data-val-regex-pattern="^[0-9]{10}$" data-val-required="*required" id="NId" maxlength="10" name="NId" onblur="LoadInfo()" type="text" value="">

Textobx Name (fill and appear after enter the NId) :

<form action="/Employees/Manager/SavePerson" data-ajax="true" data-ajax-begin="onpostcreatebegin" data-ajax-complete="onpostcreatecomplete" data-ajax-loading="#ajaxloading" data-ajax-method="post" data-ajax-mode="replace" data-ajax-update="#result" id="form0" method="post" novalidate="novalidate"><input name="__RequestVerificationToken" type="hidden" value="asdxBadsP7CpS53654as6dadH3865asdadKhjasdad">        <input type="hidden" name="empId" id="empid" value="0">
    <div class="panel panel-info">
        <div class="panel-body">
            <input data-val="true" data-val-regex="It is 10 numbers" data-val-regex-pattern="^[0-9]{10}$" data-val-required="*required" id="NId" name="NId" type="hidden" value="1234567890">
            <input data-val="true" data-val-number="The field PersonId must be a number." data-val-required="The PersonId field is required." id="PersonId" name="PersonId" type="hidden" value="254102232">
            <input data-val="true" data-val-required="The GuidId field is required." id="GuidId" name="GuidId" type="hidden" value="665xs6asd-cxc2-wq56-8888-30654998b166">
            <div class="form-group">
                <div class="col-md-4">
                    <input class="form-control text-box single-line" data-val="true" data-val-regex="enter the name." data-val-regex-pattern="^[u0600-u06ffs]+$|[u0750-u077fs]+$|[ufb50-ufc3fs]+$|[ufe70-ufefcs]+$|[u06ccs]+$|[u067es]+$|[u06afs]$|[u0691s]+$|^$" data-val-required="*required" id="Firstname" name="Firstname" type="text" value="jack">
                    <span class="field-validation-valid text-danger" data-valmsg-for="Firstname" data-valmsg-replace="true"></span>
                </div>
            </div>

        </div>
    </div>  
</form>

Answer

I guess element is taking time to be visible so please use explict wait.

Code:

element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "Firstname")) 
firstname = element.get_attribute('value')