I want to receive the site without footer but make the header exist by (I use "web view") . Can any one solve my problem in java language (Android studio)?
You can use loadDataWithBaseURL() method like below:
WebView mWebView = (WebView)this.findViewById(R.id.webview);
String mUrl=“<your website url>”;
Document document = Jsoup.connect(mUrl).get();
document.getElementsByClass("footer").remove();
WebSettings ws = mWebView.getSettings();
ws.setJavaScriptEnabled(true);
mWebView.loadDataWithBaseURL(mUrl,document.toString(),"text/html","utf-8","");
Related
Where can i find a good example of testing an excel addin project with custom ribbon elements, using winappdriver.
What i have so far throws an exception:
System.InvalidOperationException
An element could not be located on the page using the given search parameters.
I am using latest winappdriver
Code:
private const string ExcelAppId = #"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE";
private const string WindowsApplicationDriverUrl = "http://127.0.0.1:4723";
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", ExcelAppId);
appCapabilities.SetCapability("deviceName", "WindowsPC");
appCapabilities.SetCapability("platformName", "Windows");
session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
session.FindElementByName("Blank workbook").Click();
I'm working on automated testing of an Excel add-in with WinAppDriver.
In my case I started Excel without the splash screen. Supply /e as app parameter to achieve it.
session.SetCapability("appArguments", "/e");
From this point onward, you'll be able to find the "File" menu and "New" menu by name and click them.
Add a few seconds of explicit wait and proceed to finding "Blank Workbook" WindowsElement the same way.
I hope this answers your question, post here if more help is needed.
I've been experimenting with WinAppDriver for a few months now, also preparing a Udemy course on the subject which is almost ready to publish. It's an interesting toolkit.
You need to install Appium.WebDriver, Selenium.support, Selenium.webDriver from "Manage Nuget packages"
you can use appium code like:
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;
class Excel
{
public void ExcelCase() {
WindowsDriver<WindowsElement> driver;
AppiumOptions desiredcap = new AppiumOptions();
desiredcap.AddAdditionalCapability("app", #"C:\Program Files\Microsoft Office\Office16\EXCEL.EXE");
driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desiredcap);
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
if (driver == null)
{
Console.WriteLine("App not running");
return;
}
}}
Try this code and comment if you face any issue.
I prefer to use: session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); instead of Thread.sleep(5).
Does it even open the excel when you start the test?
If by Name is not working, it doens't work to me sometimes either, you can use the accessibilityId
session.FindElementByAccessibilityId("AIOStartDocument").Click();
or use the keyboard shorcut to open the blank workbook, like this:
session.Keyboard.SendKeys(Keys.Alt + "f" + "l" + Keys.Alt);
I'm creating a Post entity (Activity feed entity) within my custom C# code and I need to be able to add a hyperlink into its text field.
Creating a post entity
Entity post = new Entity();
post.LogicalName = "post";
I could simply write something like
post["text"] = "http://www.google.com"
and it would work as a hyperlink. I think there's jQuery (out of a box?) that handles formatting in that case.
But in my case I'd like to add a hyperlink with a custom title. Something similar to
Click
Is there a supported way to do this or do I need to write my own client side script for formatting purposes?
For your text box content to work as a hyperlink, the Format of the Textbox needs to be URL. If you can set the format of your textbox, then any text that you put in there ,provided it follows the rules of hyperlink, it will be displayed as one.
Are you creating the attribute, or is it an existing one that you're trying to fiddle with? If it's an existing one, you need to write your own javascript to render it on the form as a hyperlink; and this would be unsupported.
you can use hyperlink with custom title like this:
string link = "<a onclick='window.open(" + "http://localhost:49944/Default.aspx? surveyresponseid=" + SurveyResponseId.ToString() + "); ' href='" + "http://localhost:49944/Default.aspx?surveyresponseid=" + SurveyResponseId.ToString() + "' target='_blank' >click this</a>";
post["text"] = link;
I am fairly new to Word Addin development. Fortunately I was able to do almost everything but stuck at some simple issue I belive.
I want to insert plain text controls dynamically at the selected range. For this I am using the following:
currentDocument = application.ActiveDocument;
foreach(var field in myFieldsList)
{
Microsoft.Office.Interop.Word.Range rng = currentDocument.ActiveWindow.Selection.Range;
object oRng = rng;
var contentControlPlain = application.ActiveDocument.ContentControls.Add(Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlText, ref oRng);
contentControlPlain.Tag = formField.FormFieldId.ToString();
contentControlPlain.SetPlaceholderText(null, null, " <" + formField.FormFieldName + "> ");
contentControlPlain.LockContentControl = (formField.TypeName.Trim() == "Blank");
}
Code seems to be working fine but when I try to insert the second field it complains saying:
This method or property is not available because the current selection partially covers a plain text content control.
I understand that addin is trying to insert next content control into the previously inserted plain text control. But I tried giving some other range and could not fix it.
Any help is greatly appreciated.
Thanks.
After adding every content control use
Application.Selection.Start = lastControl.Range.End+1
I would like to programatically add alert to folders inside a sharepoint list. I have found how to set alerts to a list and this works perfect.
Could someone please help me on how to set alerts to a specific folder which is inside a list.
Below is the code i currently have which sets alerts only to the list.
using (SPSite site = new SPSite("http://site/"))
{
using (SPWeb web = site.OpenWeb())
{
SPUser user = web.SiteUsers["domain\\user"];
SPAlert newAlert = user.Alerts.Add();
newAlert.AlertType = SPAlertType.List;
newAlert.List = web.Lists["Documents"];
newAlert.EventType = SPEventType.All;
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
//passing true to Update method will send alert confirmation mail
newAlert.Update(true);
}
}
Your help will be much appreciated
THIS QUESTION IS RESOLVED! PLEASE SEE MY POST BELOW WITH THE LINK - SEE - LINK
That's not possible out of the box, but after googling I found an interesting possibility though, check out Mike Walsh's answer on this post, it entails creating a view in the folder and then attaching the alert to that view.
You need to update the line with
newAlert.List = web.Lists["Documents"];
With
SPFolder fldr = web.GetFolder("/ListName/FolderName");
newAlert.Item=fldr.Item;
Also note that Folder is also another item.
I am using Office Web components to fill an Excel template with values. The template is in Excel xml format, containing all relevant fields and layout options including the page layout, landscape in this case. I'm filling this template with some real fields using the code below.
Set objSpreadsheet = Server.CreateObject("OWC11.Spreadsheet")
objSpreadsheet.XMLURL = Server.MapPath("xml") & "\MR1_Template.xls"
'Fill cells with values here
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "inline; filename=" & strFileNaam
Response.write objSpreadsheet.xmlData
After the new Excel file has been saved, the page layout options are gone. I've looked at the API documentation for the OWC but cannot find the option to specify the landscape page-layout
I'm not sure if you are passing in the right data. XMLURL seems like an odd method name to be passing in a XSL template into?
If all you are doing it doing a xsl transformation then why not just use DOMXmlDocument similar to this article:
http://www.codeproject.com/KB/XML/xml_spreadsheet_to_csv.aspx
Cut and paste for ease:
Dim xslt As New XslTransform
'Load the stylesheet.
xslt.Load(Server.MapPath(".") & "excel2csv.xsl")
Dim doc As New XmlDocument
'xmldata is string, use doc.Load(fileName) for file.
doc.LoadXml(xmlData)
'Create an XmlTextWriter which outputs to a file.
Dim fileName As String
fileName = Server.MapPath(".") & "book.csv"
Dim writer As XmlWriter = New XmlTextWriter(fileName, Nothing)
'Transform the data and send the output to the console.
xslt.Transform(doc, Nothing, writer, Nothing)
writer.Close()
After some detailed comparison of the template excel sheet (as xml) and the resulting xmlData I've decided to hack the page layout in the resulting Xml. These are the options I've added:
<x:WorksheetOptions>
<x:PageSetup><x:Layout x:Orientation="Landscape"/></x:PageSetup>
<x:FitToPage/>
<x:Print>
<x:FitWidth>2</x:FitWidth>
<x:ValidPrinterInfo/>
<x:PaperSizeIndex>9</x:PaperSizeIndex>
<x:Scale>87</x:Scale>
</x:Print>
</x:WorksheetOptions>