I m automating a web application and need help at one point.
When even i login to the web app. it ask for the user name(manager id) and then that manager id keep on flashing on home page. Manager id changes with different login credentials.
So i need to keep checking that Manager id.
<tr>
<td>
<center>
<table width="100%" align="center">
<tbody>
<tr/>
<!--comments: To link all the screens-->
<tr>
<tr class="heading3" align="center">
<td style="color: green">Manger Id : mngr8499</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</body>
The manager ID as you can see in DOM is displayed as Manager Id: XXXX
So please help me how to locate these "XXXX" only, out of Manager id: XXXX
To my understanding after using getText() you get Manger Id : mngr8499 but you do not want every time Manager ID with the text and only ID. My Implementation would be to first copy the text in the any String variable and then using String.replaceAll() Method i can get the required text.
Below is the implementation of the same, Please let me know in-case if i am understanding the question wrong.
WebElement mngrid = driver.findElement(By.xpath("//tr[#class='heading3']/td"));
String actual_text = mngrid.getText();
actual_text= actual_text.replace("Manger Id :"," ");
System.out.println(actual_text);
From what I understand, I would use the .getText() method to get the 4 characters within the td using:
driver.findElement(By.cssSelector(".heading3 > td")).getText().substring(17);
If your concern is the refreshing of the html, consider using:
WebDriverWait wait = new WebDriverWait(driver, 10)
wait.until(ExpectedConditions.stalenessOf(By.cssSelector(".heading3 > td"));
When the previous value drops out of the DOM, you can use the new selector to get the refreshed value.
Related
I suffer an error trying to implement a visualforce emailtemplate. The dev console gives me the following problem on the VF component: Unknown property 'String.Name' (line 0). I can't figure out how to resolve this. Consequently the email template doesnt work & gives me the error: <c:ProductOrderItemList can only contain components with an access level of global.
I aim to send an email from a Product Order (parent). In the email I want to include child records (product order items).
Apex class:
public class ProductOrderTemplate
{
public Id ProductorderID{get;set;}
public List<Product_Order_Item__c> getProductorderItems()
{
List<Product_Order_Item__c> toi;
toi = [SELECT Product_Type__r.Name, Quantity__c FROM Product_Order_Item__c WHERE Product_Order__c =: ProductorderID];
return toi;
}
}
The visualforce component:
<apex:component controller="ProductOrderTemplate" access="global">
<apex:attribute name="ProductOrdId" type="Id" description="Id of the Product order" assignTo="{!ProductorderID}"/>
<table border = "2" cellspacing = "5">
<tr>
<td>Name</td>
<td>Quantity</td>
</tr>
<apex:repeat value="{!ProductorderID}" var="toi">
<tr>
<td>{!toi.Name}</td>
<td>{!toi.Quantity}</td>
</tr>
</apex:repeat>
</table>
</apex:component>
And the email:
<messaging:emailTemplate subject=“Product Order” recipientType="User" relatedToType=“Productorder”>
<messaging:htmlEmailBody >
Hi,<br/>
Below is the list of ... for your Product order {!relatedTo.Name}.<br/><br/>
<c:ProductOrderItemList ProductOrderId="{!relatedTo.Id}" /><br/><br/>
<b>Regards,</b><br/>
{!recipient.FirstName}
</messaging:htmlEmailBody>
</messaging:emailTemplate>
Any help much appreciated! Quite stuck on this. I'm new to visualforce and apex.
You might need just a VF email template without component and apex class. Go to Product_Order_Item__c object, find Product_Order__c field definition. Write down the "Child Relationship Name".
Let's say it'll be "Line_Items". You need to add "__r" to the end (why?) and then you can do something like that:
<messaging:emailTemplate subject="Product Order" recipientType="User" relatedToType="Productorder">
<messaging:htmlEmailBody >
<p>here are your line items</p>
<table>
<apex:repeat value="{!relatedTo.Line_Items__r}" var="item">
<tr>
<td>{!item.Name}</td>
<td>{!item.Quantity}</td>
</tr>
</apex:repeat>
</table>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
If you still think you want Apex and component (maybe you want to filter some records out, maybe you want to have them sorted or have a reusable piece of markup to use in multiple emails)...
... the error you're getting is because ProductorderID is a single String (well, Id) variable. But you've used it in a repeat that expects a list/array. A reference to <apex:repeat value="{!ProductorderItems}" var="toi"> should call your getProductorderItems() and work better.
I need to export data to an excel sheet using AngularJS(using version 1.5.x)
I tried using FileSaver.js and Alasql from the solution given in the below link
Export to xls using angularjs
I have two problems.
I need the data in excel to be customized as in below screenshot :
Format required
The required bold headers and separate rows on the top of the table I could achieve using FileSaver, but it leads to the second point.
Javascript & HTML Code -
$scope.getFile = function () {
var blob = new Blob([document.getElementById('exportable').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"});
saveAs(blob, "ProgramsInfo.xls");
}
<a ng-click="getFile()" file-download="myBlobObject">Download Report</a><a>Share</a>
<div id="exportable" style="display:none;">
<table width="100%" border="1">
<thead>
<tr><td>Client : {{client}}</td></tr>
<tr><td>Program : {{programName}}</td></tr>
<tr><td>Date Range : {{dateRange}}</td></tr>
<tr>
<th>Name</th>
<th>E-mail</th>
<th>DoB</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="program in programs">
<td>{{program.account_name}}</td>
<td>{{program.e_mail ? 'Y':'N'}}</td>
<td>{{program.dob | date:'MM/dd/yy'}}</td>
</tr>
</tbody>
</table>
</div>
Getting an error when using Firefox which states that The file you are trying to open is in a different format than specified by the file extension...
![] [Firefox Error message]2
Can anyone help me with this?
Something like this can work if you're using alasql.
$scope.getFile = function () {
alasql('SELECT * INTO XLSX("ProgramsInfo.xlsx",{headers:true}) FROM ?',[$scope.program]);
};
Also, you can give a try here http://jsfiddle.net/agershun/00nfeq12/ and check this Export Html table to Excel.
And for the error that you get The file you are trying to open is in a different format than specified by the file extension..., its actually a security feature in Excel, introduced with Office 2007, that matches the content of the file and the file name extension.
That warning will show up when the security feature is enabled and it detects possible incompatibility between the actual content of the file and the file name extension, which can cause unexpected problems.
A registry key can be edited to stop the message from displaying.
Under HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Security Add a new DWORD Value called ExtensionHardening and set it's value to 0
<tr>
<tr>
<td class="style1" valign="top"> URL : </td>
<td class="style3">
<span id="lblPresenter" class="bord">https://testurl.net</span>
</td>
</tr>
</tr>
enter code here
we1 = driver.findElement(By.xpath("//*[#id='lblPresenter']"));
System.out.println(we1.getAttribute("InnerHTML"));
//I am getting Null as result
or
System.out.println(we1.getText());
//I am not getting any result
strong text
I need to get URL from the above source code .
If any body have a solution please let me know .
In general, XPath should be avoided because it's slower and more error prone. This is a simple scenario that doesn't require an XPath. You can do the same thing using By.id()
WebElement ele = driver.findElement(By.id("lblPresenter"));
System.out.println(ele.getAttribute("innerHTML"));
System.out.println(ele.getText());
One issue with your we1.getAttribute("InnerHTML") is that the i in innerHTML should not be capitalized. Please try the above code and see if that works. If not, please post the results/errors.
I have a table that displays the list of data from websql local database.Onclick of add Button list of doctors are provided to add to the database.The adding is done but problem is that i am not able to update the datalist and see the added record.After page refreshing i could see the added record.Can anybody plz help me here.I am posting my code below.The html view template is as follows:
<table class="table table-hover" >
<tr>
<th>DOCTOR</th>
<th>SPECIALITY</th>
<th>PATCH</th>
<th>CLASS</th>
<th> </th>
</tr>
<tr ng-repeat="doc in listDoctors">
<td>{{ doc.contactName }}</td>
<td>{{ doc.speciality }}</td>
<td>{{ doc.townName }}</td>
<td>{{ doc.class }}</td></tr></table>
Now controller does:
//displays list of doctors
$scope.listDoctors = [];
readData.transaction(sqlDoctorDetails,0)
.then(function (data) {
$scope.listDoctors=data;
});
adds the data to database
$scope.AddToList = function() {
var db = openDatabase("database");
db.transaction(function(tx) {
tx.executeSql(insertStatement);
});
Please help me to improve the code to update the list on adding new entry into the database.
sqlDoctorDetails and insertStatement are my query variables for displaying and inserting data respectively.
In the AddToList function push the latest doctor details which will update the list as well
So whenever you click on the add button and call a controller function:
$scope.addDoctorToDB(doctorDetail){
//add it to the doctor's list
$scope.listDoctors.push(doctorDetail);
//Now do the db operation say calling your add function
this.AddToList();
}
My Angular knowledge is rusty but I think after you insert into the DB you need to either insert to the in-memory model listDoctors or trigger the sqlDoctorDetails query to read the updated data into listDoctors.
Angular observes your model for changes but it doesn't observe the DB behind the model.
bit of a newbie to mvc. i am having trouble with the following scenario:
I have a view with the following:
<tr>
<% foreach (var game in (IEnumerable<Game>)ViewData["Game"])
{ %>
<td>
<input type="checkbox" name="selectedObjects" value="<%=game.Id%>" />
</td>
<td>
<%=game.GMTDateTime%>
</td>
<td>
<%=game.HomeTeamId%>
</td>
<td>
<%=game.AwayTeamId%>
</td>
<td>
<%=game.Venue%>
</td>
</tr>
All of the data displays OK except for HomeId and AwayId. These two fields are linked to another table called team and each Id in HomeTeamId and AwayTeamId relate to a record in the Team table and each id has a "Name". My problem is how do I display the "Name" from the Team table rather than the Id field shown.
The controller shows:
ViewData["Game"] = dc.Games.GetGames();
The query I am using in linq is:
public static IEnumerable<Game> GetGames(this Table<Game> source)
{
return from c in source
orderby c.GMTDateTime
select c;
}
Assuming you have defined the relationships in your schema, this should work:
<td>
<%=game.Team.Name%>
</td>
<td>
<%=game.Team1.Name%>
</td>
Because there are multiple FKs to the Team table, you will see two properties for Team, Team and Team1 (or similar). You'll need to determine which is which by looking at the generated LINQ code, or by trial and error, i.e., observing the output.
Normally using partial classes I will make additional properties that expose the Team object(s) with better names that make it clear which FK they are for.