I'm Trying to create new instance of a DotNetBrowser and assign it to my panel inside windows forms.
Based on DotNetBrowser start guide, to create new instance of browser (that have its own cache, etc) I need to do following:
BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
BrowserContext context1 = new BrowserContext(params1);
Browser browser1 = BrowserFactory.Create(context1);
My question is, what do I do with this browser now?
I want to asign it to my browserpanel like this
browserpanel.Controls.Add(browser1);
But this will not work because I need to have object of a class
WinFormsBrowserView to assign it to browserpanel. And If I create object of a type WinFormsBrowserView, I cant customize it as documentation explains.
And the Browser inside newly constructed WinFormsBrowserView is readonly, so i cant assign this browser to it.
Found solution:
BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
context1 = new BrowserContext(params1);
browser1 = BrowserFactory.Create(context1);
WinFormsBrowserView browserview = new WinFormsBrowserView(browser1);
Related
I have this:
Crew_Photos photos = new Crew_Photos(); // contains List<t> of photos
Bus_Crew buscrew = new Bus_Crew(); // Calls update.AddUpdate()
Cab_Crew cabcrew = new Cab_Crew(); // Also calls update.AddUpdate()
UpdateCrew update = new UpdateCrew(); // DEFINES method AddUpdate();
I'm trying to avoid doing this:
Crew_Photos photos = new Crew_Photos();
Bus_Crew buscrew = new BusDriver_Crew(photos);
busscrew.AddUpdate(photos);
Cab_Crew cabcrew = new Cab_Crew(photos);
cabcrew.AddUpdate(photos);
UpdateCrew update = new UpdateCrew(photos);
I do not want to pass photos to Bus_Crew, and Cab_Crew, only so that I can then pass it again to UpdateCrew() which is actually going to use it.
How can I make Crew_Photos photos available to update.AddUpdate() when it is called by buscrew.AddUpdate() and cabcrew.AddUpdate()?
How about a constructor for UpdateCrew that receives the three things?
UpdateCrew update = new UpdateCrew(new Crew_Photos(), new BusDriver_Crew(), new Cab_Crew());
Then the constructor can call AddUpdate() internally?
It's not clear what is happening within the different classes, so answering this question is very difficult.
How can I use "sendkeys" or find new elements in a new opened browser window and return back to my old window?
Here is the code I have so far:
DesiredCapabilities EQcapabilities = new DesiredCapabilities();
EQcapabilities.SetCapability("appTopLevelWindow", EQWindowHandle);
var EQSession = new WindowsDriver<WindowsElement>(
new Uri("http://127.0.0.1:4723"), EQcapabilities);
// new window:
EQSession.FindElementByName("...").Click();
// I have tried this, but it is not working
String newWindowHandle = EQSession.WindowHandles.Last();
var newWindow = EQSession.SwitchTo().Window(newWindowHandle);
newWindow.sendkeys("some text");
You're sending the keys to the window. Find the element that you want to send them to first, and use SendKeys on that.
In want to add a copy of an object to a List in a universal Windows Application. I tried several ways and found IClonable,BinaryFormatter,IFormatter which are all not available in WinRT applications. Please advice me a suitable way to copy a object to a new object. Find my code below.
foreach (var ctrls in _listctrldata)
{
for (int index = 0; index < ctrls.Controls.Control.Count; )
{
listofcontrolvalues.Add(ctrls.Controls.Control[index]);
index++;
}
SetControlvalues(null, _vcontainer, listofcontrolvalues);
//_vcontainer changes everytime the loop rotates and Should create a copy of _vcontainer here//
VerticalContainer vcont = new VerticalContainer ();
vcont = _vcontainer;
_listcontrols.Add(vcont);
}
I don’t know what the class VerticalContainer is.
If it is a .NET class defined by you self, you can just defined a clone method to create a new object and copy all of the build-in data type fields.
If it is a Windows Runtime class, I’m afraid you cannot easily copy it because there are some internal and private data members you cannot access.
In your code.
VerticalContainer vcont = new VerticalContainer (); vcont = _vcontainer;
You only changed the vcont reference from new created object to the old _vcontainer, this will not work, you need to copy all of fields from _vcontainer to vcont one by one.
I am starting to get into C# from years of other languages, and I feel so basic for even asking this, but I have been scouring this site and the net and just cannot seem to get this to sink in and work. I am trying to create a framework in coded UI so that I can have a library of methods to call to perform actions on browser controls. Here is one of the methods I am trying to use:
namespace Functions
{
public class BrowserFunctions()
{
public BrowserWindow browser {get;set;}
public object launchBrowser()
{
browser = BrowserWindow.Launch(new Uri("https://qawww.test.com/"));
browser.Maximized = true;
return browser;
}
}
}
I want to then be able to reference the browser object I am trying to return from this script:
BrowserWindow mybrowser = new Functions.BrowserFunctions.browser;
^^ this line says it is a property but used like a type
//BrowserWindow mybrowser = Functions.BrowserFunctions.browser;
// mybrowser = new BrowserFunctions();
UITestControl txtUserEmail = new UITestControl(mybrowser);
UITestControl txtPassword = new UITestControl(mybrowser);
UITestControl btnLogin = new UITestControl(mybrowser);
I am probably way off base and still trying to learn, but currently failing :) I am grateful to anyone who could help get me going with this.
BrowserWindow mybrowser = new Functions.BrowserFunctions.browser;
This line literally isn't doing anything. You need to either create a new BrowserFunctions object and then assign the browser to it through a set method such as this....
BrowserWindow mybrowser = new Functions.BrowserFunctions.browser();
mybrowser = somebrowser;
Or you have one already existing and you don't need to new it.
BrowserWindow mybrowser = Functions.YourBrowserFunction.yourbrowser;
I want to programatically create list on Sharepoint using Web Services.
I tried "Lists.AddList Method" but it would create list in current site only.
Is there any other way to create list? (Using Web Services : C#)
You can create SPWeb object of the desired location and add list in it dynamically. See following:
http://msdn.microsoft.com/en-us/library/ms425818.aspx
Have you tried this MSDN page, Lists.AddList Method (Lists)?
I think here you can find what you need.
To Create List on specified path
Lists listService = new Lists();
listService.PreAuthenticate = true;
listService.Credentials = new NetworkCredential(username,password,domain;
String url = "http://YourServer/SiteName/"; // put your desired path here
listService.Url = url # + /_vti_bin/lists.asmx";
XmlNode ndList = listService.AddList(NewListName, "Description", 100);