html dropdown containing list python output - python

I am trying to use the list from my python output into a dropdown menu in an HTML form.
I have a website built in HTML/ CCS, a server with nodeJS, and several scripts i want to use in python3.
I currently have no idea how to integrate the python output to the dropdown. Do i need to use Javascript or my node server is enough?
My HTML form
<form action="/LUNProvisionning" method="post">
<fieldset>
<legend>LUN Provisionning</legend>
<br />
<label>Choix du serveur : </label>
<select id="serveur" name="serveur">
# put python output here!!
<option value="1">no serveurs</option>
</select>
<br />
<label>Volumétrie en Go 5 - 1000 : </label>
<input type="number" min="5" max="1000" placeholder="500" name="volumetrie" required>
<br />
<label>Type de provisionning : </label>
<select id="provisionning" name="type" required>
<option value="Thin">Thin</option>
<option value="Deco">Deco</option>
</select>
<br/>
<input type="submit" value="Submit">
</fieldset>
</form>
python output:
SSD_r1
SSD_r5
SSD_r6
fs_cpg
CPG4S2
These need to be in the dropdown above.
I have a node server that i can show if it's relevant.
Thank you very much for your help.
Any informations or links, anything can help.

Related

automate filling in web forms

There is a text box (ID) on the website and I want to put 10,000 data in it. After placing each data in this text box, results are displayed in other text boxes according to the ID.
Textbox ID :
<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 after enter the ID in text box) :
<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-\u06ff\s]+$|[\u0750-\u077f\s]+$|[\ufb50-\ufc3f\s]+$|[\ufe70-\ufefc\s]+$|[\u06cc\s]+$|[\u067e\s]+$|[\u06af\s]$|[\u0691\s]+$|^$" 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>
The page will not reload after entering the value in the text box ID. Shows the value on that page. What solution do you suggest? I do not know which method to consider that is the most optimal method. Can you introduce the most optimal and practical method?
Depending on how complex the task is, you can use either Selenium (Selenium is a script-controlled Browser) with Firefox WebDriver, for example.
It is of course also possible to use the request methods GET and POST as a method with more work but much higher performance.

I am unable to select/enter data into a text area using selenium

Below is the html code of text area I am trying to automate :
<div class="large-5 end columns chckOutNote">
<input id="LocationNotes_0__LocationNumber"
name="LocationNotes[0].LocationNumber" type="hidden" value="Location1">
<input id="LocationNotes_0__ServiceProviderName"
name="LocationNotes[0].ServiceProviderName" type="hidden" value="trial">
<input id="LocationNotes_0__WasPreviouslyFilled"
name="LocationNotes[0].WasPreviouslyFilled" type="hidden"
value="False">
<label for="LocationNotes_0__Note"> trial</label>
<br>
<span id="LocationNotes_0__Note">500</span> characters
remaining
<textarea class="counterpart" data-counter-
part="#LocationNotes_0__Note" data-max="500" data-val="true" data-val-
length="The field Note must be a string with a maximum length of 500."
data- val-length-max="500" data-val-required="The Note field is
required."id="LocationNotes_0__Note" name="LocationNotes[0].Note"
rows="10">
</textarea>
</div>
I tried to click on the element and then enter the data thru send keys but its throwing an error that it cannot find the focus of the element

Multiple inputs with same name through POST in bootstrap?

Multiple inputs with same name through POST in php
I've looked at this and I was hoping I could get something similar with python and bootstrap but it just shows Nonetype with "key[]" or the last value if I just use "key".
<div class="form-check">
<label class="form-check-label" tal:repeat="a keys">
<input type="checkbox" name="key[]" value="${a.id}">${a.name}
</label>
</div>
Is there a way to do this?

webdriver.support.select - Select doesn't interact with the element

Hello,
I have the following select:
<div class="col-xs-12 col-md-6">
<label class="ph_label pointer city">
<span class="l citylbl">City</span>
<select class="cities custom-dropdown" data-validation-error-msg="You must select a city" required="" name="city" disabled="disabled" data-validation="required">
<option value="">City</option>
<option value="Shanghai">Shanghai</option>
<option value="Beijing">Beijing</option>
<ul class="cities custom-dropdown" data-target-selector="select.cities" style="width: 293px;">
</label>
</div>
I'm trying:
mySelect = Select(self.driver.find_element_by_name("city"))
mySelect.select_by_value("Shanghai")
When I see the test run, selenium goes through this element as if everything was OK, but in fact the city was not selected.
Any ideia?
I think this is due to the select in the code snippet is marked as disabled?
I have tried using Watir-webdriver, and if the disabled="disabled" attribute is there, I get the behavior you describe. As soon as I remove it, the value I want is selected.

Jinja 2 - Django Form : rendering encodes HTML

I was testing Jinja2 in a Django project and have a strange output.
When I render the form, some characters are HTML encoded (< > etc.)
In the template :
{{ form.as_p() }}
It renders to the browser :
<p><label for="id_username">Utilisateur:</label> <input autocomplete="off" id="id_username" type="text" name="username" maxlength="100" /></p> <p><label for="id_password">Mot de passe:</label> <input autocomplete="off" type="password" name="password" id="id_password" /></p>
Looking at sources :
&lt;p&gt;&lt;label for=&quot;id_username&quot;&gt;Utilisateur:&lt;/label&gt; &lt;input autocomplete=&quot;off&quot; id=&quot;id_username&quot; type=&quot;text&quot; name=&quot;username&quot; maxlength=&quot;100&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label for=&quot;id_password&quot;&gt;Mot de passe:&lt;/label&gt; &lt;input autocomplete=&quot;off&quot; type=&quot;password&quot; name=&quot;password&quot; id=&quot;id_password&quot; /&gt;&lt;/p&gt;
Does anyone know this problem ?
Jinja2 tries to be safe by HTML-escaping the data. So you have to use |safe filter.
Though I haven't used Django with Jinja2, I believe this should work:
{{ form.as_p()|safe }}

Categories