I have a telerik grid in my mvc application with a edit button.
When I click on this button I get another template from SharedTemplates based on the same model of the grid view.
In my editor template, if I declare a field using this:
#Html.EditorFor(a => a.Order)
Html generated:
<input class="text-box single-line valid" id="Order" name="Order" type="text" value="000020">
As you can see, I got the order value from the grid when I clicked on the edit button. But if I declare the same field not using the model, like this:
<input type="text" id="Order" name="Order" style="width: 100px; background-color: lightgrey" />
Html generated:
<input type="text" id="Order" name="Order" style="width: 100px; background-color: lightgrey">
Basically, the question is: Why if I put #Html.EditorFor(a => a.Order) I get the order value when I click edit, and I cannot get the order value when I use the
input type="text" id="Order" name="Order" style="width: 100px; background-color: lightgrey" />
Related
I need to select values (any value from House_TypeList) from dropdown menu with NUnit or just pure selenium. .
They are not seen in HTML.
I have tried select by xpath, by name, by span contains etc etc, I tried sending down key. I have waited for the element to become visible. I am out of ideas. Nothing works. I have not tried yet moving the cursor and trying to select it by that, but had a few problems implementing it and having in mind my luck, not really believing it will work either..
I am a beginner here, maybe I did some mistakes there. But I successfully managed any other inputs, buttons, navigation..
I have checked other similar questions, but could not find the answer that would work for me.
Is it even possible here?
Source:
<div class="dx-item dx-box-item" style="display: flex; min-height: auto; flex-grow: 1; flex-shrink: 1;"
<div class="dx-item-content dx-box-item-content" style="width: auto; height: auto; display: flex; flex-direction: column; flex-basis: 0px; flex-grow: 1;">
<div class="dx-first-col dx-last-col dx-field-item dx-field-item-required dx-col-0 dx-flex-layout dx-label-h-align">
<label class="dx-field-item-label dx-field-item-label-location-left" for="dx_dx-...._typeId">
<span class="dx-field-item-label-content" style="width: 159px;">
<span class="dx-field-item-label-text">Type:</span>
<span class="dx-field-item-required-mark"> *</span>
</span>
</label>
<div class="dx-field-item-content dx-field-item-content-location-right">
<div class="dx-textbox dx-texteditor dx-texteditor-empty dx-dropdowneditor-button-visible dx-widget dx-dropdowneditor-field-clickable dx-dropdowneditor dx-selectbox dx-validator dx-visibility-change-handler" id="slb_HouseManagement_EditHouse_TypeList">
<div class="dx-dropdowneditor-input-wrapper dx-selectbox-container">
<input type="hidden" value="" name="typeId">
<div class="dx-texteditor-container">
<input autocomplete="off" id="dx_dx-4e..._typeId" class="dx-texteditor-input" aria-haspopup="true" aria-autocomplete="list" type="text" readonly="" spellcheck="false" tabindex="0" aria-expanded="false" role="combobox" aria-required="true">
<div data-dx_placeholder="Select..." class="dx-placeholder"></div>
<div class="dx-texteditor-buttons-container">
<div class="dx-dropdowneditor-button dx-button-normal dx-widget" type="button">
<div class="dx-button-content">
<div class="dx-dropdowneditor-icon"></div>
</div></div></div></div></div></div></div></div></div></div>
Done. Found it in Devextreme support, the user had a bit different problem, but it solved mine as well.
IWebElement selectedItem = driver.FindElement(By.XPath("//div[#role='option']/div[text()='Apartment']"));
selectedItem.Click();
The DOM you have provided here does not contain any element for Lists. So I cannot share exact working code here. I will share few sample which you can update and use
With Selenium to select items from a list, you have two options to choose from:-
Select Class
Make an object of select class like below
Select obj =new Select(driver.findElement(By.id("search-box")));
Then you can use several functions on this select obj
obj.selectByVisibleText("Apartment");
Or
obj.selectByIndex(2);
or
obj.selectByValue("Farmhouse");
You can also get all the element in a List and then work around that list
List <WebElement> myHouseList = obj.getOptions();
System.out.println(myHouseList.size());
2.Actions Class
driver.manage().timeouts().implicitlyWait(10 , TimeUnit.SECONDS);
ele= driver.findElement(By.linkText("HouseList"));
Actions act = new Actions(driver);
act.moveToElement(ele).click();
WebElement webele = driver.findElement(By.linkText("Apartment"));
act.moveToElement(webele).click().build().perform();
Hope this helps you!!
I'm trying to create a program that will programmatically complete a form.
The payee field on the form uses a searchable listbox.
I'm using the code below to place the text in the drop down box, but it's not activating it as though it was searched and selected from the list.
webBrowserWB.Document.GetElementById("select2-chosen-4").InnerText = payee;
How would I mimic key strokes to type the value that I need placed in that field? Or is there another option?
Example of the list box is in the image below. Values don't appear until the user begins typing in the field.
Edited to include HTML
<div class="select2-drop select2-display-none select2-with-searchbox
select2-drop-active" id="select2-drop" style="display: block; left:
6.5px; width: 781px; top: 240px; bottom: auto;">
<div class="select2-search">
<label for="s2id_autogen4_search" class="select2-
offscreen">Payee</label>
<input type="text" autocomplete="off" autocorrect="off"
autocapitalize="off" spellcheck="false" class="select2-input"
role="combobox" aria-expanded="true" aria-autocomplete="list" aria-
owns="select2-results-4"id="s2id_autogen4_search" placeholder="">
</div>
<ul class="select2-results" role="listbox" id="select2-results-4"><li
class="select2-no-results"></li></ul></div>
Rather than using the WebBrowser control, I was able to resolve my issue by using Selenium.
I would like to get value from label with id=lblValue. On page confirm I see confirmed HTML as:
<span class="treeColorOrderBefPrepare">~
<div style='display:inline-block;'>
<img onclick='calculateDate.add(this);' style='cursor:pointer;' class="imageInBox" src="/_assets/images/icons/small/add.png"/>
<img onclick='calculateDate.subtract(this);' style='margin-left:3px;cursor:pointer;' class="imageInBox" src="/_assets/images/icons/small/subtract.png"/>
<label id='lblValue' style='position:relative;top:1px;width: 13px; height: 13px;margin-left:3px;margin-right:3px;'>0</label>
</div>
<img class="imageInBox" src="/_assets/images/icons/small/icon-small-merchandise.png"/>POPER ČRNI MLETI (0,0 KG) (fina. HKJ_TK, predp. Cent.predp: 04.04.2017 - 0,0 KG)</span>
<input type="text" name="DK_m_1_3_120000204_140000240-120003917-120000204-" value="">
All I need is to get value from lblValue. Is there a way to get this value? Values will range from -10 to 0. In the example above, value=0. I am doing this on the server side, not on the client side.
<script type="javascript">
document.getElementById("lblValue").innerHTML
</script>
Add runat="server" attribute like this:
<label id='lblValue' runat="server" style='position:relative;
top:1px;width: 13px; height: 13px; margin-left:3px;margin-right:3px;'>0</label>
and you will be able to use lblValue as a variable.
For more information, what runat attribute is doing, please see this: Why does ASP.NET webforms need the Runat="Server" attribute?
<asp:TextBox ID="givennametb" runat="server" BackColor="White" ForeColor="Black" Width="145px" CssClass="textbox"></asp:TextBox>
<asp:TextBox ID="familynametb" runat="server" BackColor="White" ForeColor="Black" Width="145px"></asp:TextBox>
I wrote this piece of code. Now I want to change bordercolor of givennametb textBox to blue and familynametb to red.
I do not want to do it inline withBorderColor:"blue/red". I want to use CSS/CSSClass. I am using C# with ASP.NET. If I do cssClass="textbox" and try to change in style, all tags are changing to same color. I want to change separately.
Remember, ASP.Net is going to render the control ASP:Text for the web browser in a <Input type="text"> of a <form> HTML, so you can use a CCS Selector with the Id of control to modify the border color of textBox.
input#givennametb{
border:1px solid blue;
}
input#familynametb{
border:1px solid red;
}
<input id="givennametb" type="text" />
<input id="familynametb" type="text" />
input.textbox#givennametb{
border:1px solid blue;
}
input.textbox#familynametb{
border:1px solid red;
}
<input id="givennametb" type="text" class="textbox" />
<input id="familynametb" type="text" class="textbox" />
I am building a Dashboard app in asp.net. I have placed 3 input buttons inside a div tag. When a user is moused over a table cell I would like for the buttons to show. How can I accomplish this using .css, javascript or jQuery?
My HTML looks like this:
<td id="bold_cell1" valign="top" width="33%" Height="33%">
<div id="buttonBlock">
<input type="button" id="btnAdd" value="Add" style="font-size:8px" />
<input type="button" id="btnEdit" value="Edit" style="font-size:8px" />
<input type="button" id="btnDelete" value="Delete" style="font-size:8px" />
</div>
</td>
Thanks
The old-fashioned way: CSS:
#buttonBlock input{
display:none;
}
#bold_cell1:hover #buttonBlock input{
display:block;
}
demo link