I need to click on tab "Pis/Cofins" in my application
<ul class="nav nav-tabs" id="tabs">
<li class="">
Dados Gerais
</li>
<li class="active">
Pis/Cofins
</li>
<li>
Combustíveis
</li>
<li>
Modo de Servir
</li>
<li>
Imagens
</li>
<li>
Informações
</li>
</ul>
You may simply use the following xpath:
//a[text()='Pis/Cofins']
You may use extension like Firebug in firefox to easily find locators and use them in your test scripts
As per the HTML you have shared to click on tab with text as Pis/Cofins you can use either of the following solutions:
LinkText:
driver.FindElement(By.LinkText("Pis/Cofins")).Click();
CssSelector:
driver.FindElement(By.CssSelector("ul.nav.nav-tabs#tabs a[href$='pisCofins']")).Click();
XPath:
driver.FindElement(By.XPath("//a[contains(#href,'pisCofins') and contains(.,'Pis/Cofins')]")).Click();
Related
I have a ASP-WebForm-Application with several User-Rights.
In CodeBehind I am hiding some Elements if the specific Rights aren't given. But with F12 the User could manipulate the Code the get some Functionallity he isn't allowed to.
Are there any possibilities to hide Elements from CodeBehind, that they aren't make visible via Code-Manipulation? Something like destroying them completely in CodeBehind?
For example a Navigation based an List-Element, where I want to hide some Links:
<ul>
<li>
<a>link 1<a/>
</li>
<li>
<a>link 2<a/>
</li>
<li>
<a>link 3<a/> // Has to be hidden by some conditions
</li>
</ul>
Hope someone could help me!
You can use the asp:PlaceHolder or the asp:Panel and warp your content and make it visible or not.
Alternative you can add on the element the runat="server" Visible="false" and manipulate the visible.
Examples:
<ul>
<li>
<a>link 1<a/>
</li>
<li>
<a>link 2<a/>
</li>
<li runat="server" id="pnlToHide">
<a>link 3<a/> // Has to be hidden by some conditions
</li>
</ul>
or
<ul>
<li>
<a>link 1<a/>
</li>
<li>
<a>link 2<a/>
</li>
<asp:PlaceHolder runat="server" ID="pnlToHide2">
<li>
<a>link 3<a/> // Has to be hidden by some conditions
</li>
</asp:PlaceHolder>
</ul>
and on code behind
pnlToHide.Visible = false;
I have an ASP.NET webforms project with a master page using adminlte UI.
I created a web site with default project in Visual Studio and then change the project to apply adminlte dashboard, copied all scripts and bootstrap then change master page and default form.
My problem: in menu sidebar when I tried to add from to root folder and do this
<li>
<a runat="server" href="Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
everything is ok and form loads without any problem.
But when I created a folder Track and created a new form inside it and try to do this
<li>
<a runat="server" href="~/Track/Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
I get this exception:
exception
What I tried
First attempt:
<li>
<a runat="server" href="../../Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
Second attempt:
<li>
<a runat="server" href="../Track/Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
Third attempt:
<li>
<a runat="server" href="~/../Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
Final attempt:
<li>
<a runat="server" href=~/Track/Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
I've fixed some deprecated and superfluous markup - adjust any related CSS selectors.
Try this:
<li>
<a runat="server" href="~/Shipment.aspx">
<em class="fa fa-th">Shipment</em>
</a>
</li>
The "~/" should resolve anything from the main project root down, presuming there are no page name conflicts. Some of your attempts should have worked so I'm thinking maybe something else is causing a problem. Presuming your menu is in a User Control, maybe it's the path to this control in your Master Page(s) that is causing the problem?
I have just created a link to route in Site.Master but it have created a weird error
For example, when it was clicked, instead of http://localhost/Admin/ManageType it became http://localhost/~/Admin/ManageType.
I have tried to solve it myself by removing ~/ and it works but it come with a flaw. Once click it work and bring you to the page but when click again, it become http://localhost/Admin/Admin/ManageType instead of http://localhost/~/Admin/ManageType.
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li class="dropdown">
Manage <b class="caret"></b>
<ul class="dropdown-menu">
<li>Recipe</li>
<li class="divider"></li>
<li>Type</li>
</ul>
</li>
<li><a runat="server" href="~/Recipe/Recipe">Recipe</a></li>
</ul>
Use Control.ResolveUrl method instead.
And you need to change:
<li>Recipe</li>
To:
<li><a href="<%= Page.ResolveUrl("~/Admin/ManageType") %>" title="ManageType" >ManageType</a></li>
Try this:
<li>Type</li>
I have html code, which looks like that:
<p>Some text</p>
<p>Some text</p>
<h2>title</h2>
<ul>
<li> element </li>
<li> element </li>
<li> element </li>
...
</ul>
<h2>title 2</h2>
<ul>
<li> element </li>
<li> element </li>
<li> element </li>
...
</ul>
etc.
My question is: how can i get all < li> elements into a List? I don't need titles, i just want elements from lists.
I think HTML Agility Pack could be a solution, but i have no idea how to do that. Thanks for help!
Didn't work dropdownlist Risk Content in master page after change page to the setting page. The dropdown just work after go back to home page again
MasterPage.master
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav custom_nav">
<li class="">Home
</li>
<li class="dropdown">Risk Context
<ul class="dropdown-menu" role="menu">
<li>Objective (KPI)
</li>
<li>Risk Limit & Expected Residual Risk
</li>
<li>Impact Scale Tables
</li>
<li>Probability Scale Tables
</li>
</ul>
</li>
<li>Settings
</li>
<ul>
</div>
What I miss from my code?? help me. thank before..