My project was already on C#7.0:
and I already have Compilers and System.ValueTuple installed:
My view model WAS:
#model IEnumerable<GHCOMvc.Models.PriorAddressModel>
<table class="table">
<tr>
<th>
#Html.DisplayNameFor(model => model.Address.Address)
</th>
</tr>
</table>
and it was all working.
When I changed it to this:
#using GHCOMvc.Controllers
#model (IEnumerable<GHCOMvc.Models.PriorAddressModel> List, BaseController.Modes mode)
<table class="table">
<tr>
<th>
#Html.DisplayNameFor(model => model.Address.Address)
</th>
</tr>
</table>
it gave the error:
Error CS8059 Feature 'tuples' is not available in C# 6. Please use
language version 7 or greater.
This isn't a core project so I don't have a Startup.cs file yet. I could add one to solve the problem, but I'm not clear on how to do that since this isn't a core project.
Updating to Microsoft.CodeDom.Providers.DotNetCompilerPlatform 1.0.4 from 1.0.3 solved the issue for me:
Note I had to manually edit the csproj file to remove the references to 1.0.3 after I did this, to get it to build.
Then, in my view, I can do:
#model (IEnumerable<GHCOMvc.Models.PriorAddressModel> list, BaseController.Modes mode)
<table class="table">
<tr>
<th>
#Html.DisplayNameFor(model => model.list.FirstOrDefault().Address.Address)
</th>
</tr>
</table>
I don't know your specific issue, but I've ran in to similar before when compiling razor files. Check your target framework. Remember, razor is compiled after deployment. I bet you'll see your issue resolved if you rev your target framework.
Related
I want to read two elements from a web page, store their text in two variables and open a new window with an URL dependent of the variables' contents.
This is what my Selenese HTML looks like:
<tr>
<td>storeText</td>
<td>//dd[2]/strong</td>
<td>str</td>
</tr>
<tr>
<td>storeText</td>
<td>//dd[3]/strong</td>
<td>plz_ort</td>
</tr>
<tr>
<td>echo</td>
<td>${str} ${plz_ort}</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>500</td>
<td></td>
</tr>
<tr>
<td>openWindow</td>
<td>https://www.google.de/?q=${str}%20${plz_ort}</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>name=btnG</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=lu_map</td>
<td></td>
</tr>
I am using the echo to manually verify that the textual content of the elements has correctly been read. However, the Selenium IDE throws an error at the openWindow step:
[warn] Opening window '_blank', which is not a real window name.
Randomizing target to be: selenium_blank19164
[error] Unexpected Exception: TypeError: result is null.
I have also tried to give the openWindow command a window name in the Value field (e.g. "random", "_blank", "foobar"), but this didn't work either.
The strange thing I wonder about: when I manually execute the command where the IDE fails it perfectly opens my window, even if still a warning is issued:
[warn] Opening window '_blank', which is not a real window name. Randomizing target to be: selenium_blank23341
Debugging in the IDE shows that the error message also comes form the openWindow command.
I did not find related questions on SO. Any help how to further debug or fix this is very much appreciated.
Problem solved. I was using Firefox' pop-up blocker and did not pay attention to the original page. Adding the AUT to the exception list fixed the problem for me.
How to do with the Element ID changing repeatedly in selenium IDE ?
this comes when I click in the button and refresh the page and click it again !
<tr>
<td>open</td>
<td>/FEP/LoginHandlerServlet.htm</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=a2uPu0</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=tU9Pu0</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=qXCPu0</td>
<td></td>
</tr>
My web application develop with ZK ( Zkoss)!
any idea?
Try finding the element by xpath or by link text, not by ID.
by linktext:
driver.findElement(By.linkText("Link text")).click();
by xpath:
findElement(By.xpath("your xpath")).click();
I gouess in YOur situation linktext would be better.
This is a common problem that I find with certain web frames (e.g. Wicket) where the HTML id changes each time the web page is rendered. If the development team is on board with automating your tests, then there is typically a way to make these ID's static, solving your problem. Otherwise, as mentioned previously you have to use some other identifying tag.
Here is a good website to get you started on all of the available options that you have at your disposal.
I am first time using Selenium for automating some developer tests.
I have some intermediate steps, which needs to run based on certain condition like a while loop
<tr>
<td>clickAndWait</td>
<td>//a[contains(text(),'active listings')]</td>
<td></td>
</tr>
//while(delist elementPresent) -----------------------------
<tr>
<td>verifyElementPresent</td>
<td>name=delist</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=listing_check_all</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=delist</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td> ------------repeated step
<td>name=delist</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=listing_check_all</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>name=delist</td>
<td></td>
</tr>
//end while (i.e. delist element no longer present) ---------------
<tr>
<td>verifyText</td>
<td></td>
<td>No active listings found</td>
</tr>
One more question, can I automate this process from command line?
I can write a script (.bat/.sh) to automate the test case run.
Note: Please do understand that I am using selenium for the first time, just to automate few dev tests.
Selenium IDE doesn't give looping functionality, you will need to install an add on like this: https://github.com/darrenderidder/sideflow
There are plugins you can add to Selenium IDE that will help you accomplish loops. You can look at a list of plugins here.
I believe the plugin you're look to achieve the while loop with is called SelBlocks. I believe the Flow Control plugin does this as well. I've used this in the past with great success. A few things to note though:
(1) Don't expect documentation for these commands to show up in the Reference tab. You'll have to read the Selblocks Reference page listed with the plugin for examples on how to implement its commands.
(2) If you intend to export your 'Selenese' code over to Java, C#, Python, or any other language, these commands won't export over. You'll have to hard code anything you created that's directly associated with any plugin command('s) you used (i.e. while, for, if, etc...) in that programming language's native code.
Hope this helps someone out.
I am trying to run a test recorded using selenium IDE. The following html is generated by the IDE
<tr>
<td>clickAndWait</td>
<td>css=span.blt-txt</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pt1:svMenu:np1:6:cni1::disclosureAnchor</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pt1:r5:0:mr1:gts1:gts_pc1:itFilterFieldValue::content</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pt1:r5:0:mr1:gts1:gts_pc1:cil1::icon</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pt1:r5:0:mr1:gts1:gts_pc1:tt1:0::di</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pt1:r5:0:mr1:gts1:gts_pc1:tt1:1:astTreeSNo</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=pt1:r1:0:rAstDtl:0:cb4</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id('pt1:ptGeneric:ot1::_afrTtxt')/x:div/x:h1</td>
<td></td>
</tr>
When I run the test/execute command I get an error saying [error] Element id=pt1:r5:0:mr1:gts1:gts_pc1:tt1:0::di not found
Any ideas how I can fix this?
the id seems to be generated try not to use this id or use contain
(try to use other xpath)
i would use only the last word of the id (you need to check it)
3.you can highlight to see where you are
example for contain
./li[contains(.,'Model')]]
Using generated ID in a testcase is usually a bad idea. When the server restarts / data change, these IDs tend to change, too.
Anyway, your problem seems to be the classical problem with timing. Are your elements AJAX-loaded when something is clicked / after a page change? If yes, Selenium tries to click them before they get fully loaded. You should use waitForElementPresent before you click on the element that causes trouble.
Generally, using Selenium IDE for AJAX-heavy pages uses to get hard very easily. Consider switching to manual Selenium RC writing or, even better, Selenium WebDriver. You can have the best of both worlds - first click through your test in IDE, then export your code to WebDriver in any language, make required changes, add waits (implicit are often enough), you're done.
Since I have installed the mvc4 RC, the razor autoresolve url that replaces ~ by the application root does not work in html 5 data-* attributes. ie:
In ASP.NET MVC4 beta :
<table id="userTable" class="dataTable" data-table-source="~/api/user/Users">
<tr>
<td data-field="OperatorCode">
#user.Code
</td>
<td>
edit
</td>
</table>
was transformed in
<table id="userTable" class="dataTable" data-table-source="/api/user/Users">
<tr>
<td data-field="OperatorCode">
operatorCode 1
</td>
<td>
edit
</td>
</table>
but in RC it is transformed in:
<table id="userTable" class="dataTable" data-table-source="~/api/user/Users">
<tr>
<td data-field="OperatorCode">
operatorCode 1
</td>
<td>
edit
</td>
</table>
As you can see in this version the ~ remains.
Is it by design ? If yes, is there any configuration parameter to change in order to reactivate the resolution in html5 data-* attribute? I have no found the explanation in the release notes.
Thank you.
This also happens in MVC4 final. It makes sense that this is by design to avoid cases where you don't want to have "~" resolved for certain data parameters.
Easy fix is to wrap them in #Url.Content again, not as nice but it works.
<html data-root="#Url.Content("~/")">
PS. I checked the MVC4 source code. There are no options to enable resolving of "data-" attributes. "data-" attributes are simply treated as literals.