Launch Chrome Incognito in LeanFT

Question ID: 109421
0
0

I’m using LeanFT (UFT Developer) and doing tests using Chrome. One of my test cases requires Chrome to be in Incognito mode. I can’t seem to figure out how to launch Chrome Incognito from LeanFT.

Marked as spam
Posted by (Questions: 328, Answers: 10)
Asked on March 26, 2020 2:38 pm
15 views
Answers
1
Private answer

I found a way to do this. Basically you need to configure the LeanFT Extension to allow Incognito mode. Then in your code, launch Chrome as usual and perform DeviceReplay steps to open an Incognito browser. Close the original browser, and attach the new incognito browser.

var browser = BrowserFactory.Launch(BrowserType.Chrome);
Keyboard.KeyDown(157); //hold down Control key
Keyboard.KeyDown(42); //hold down Shift key
Keyboard.PressKey(49); //press N
Keyboard.KeyUp(157); //release Control key
Keyboard.KeyUp(42); //release Shift key

browser.Close(); //Close original browser

//Attach new incongnito browser
var IncogChrome = BrowserFactory.Attach(new BrowserDescription
{
Title = "New Tab"
});

//Do test stuff
IncogChrome.Navigate("http://google.com");

var search = IncogChrome.Describe<IEditField>(new EditFieldDescription
{
Name = @"q"
});
search.SetValue("Orasi Software");
var googleSearchButton = IncogChrome.Describe<IButton>(new ButtonDescription
{
AccessibilityName = @"Google Search",
ButtonType = @"submit",
Name = @"Google Search",
Role = string.Empty,
TagName = @"INPUT",
Index = 1
});
googleSearchButton.Click();

var link = IncogChrome.Describe<ILink>(new LinkDescription
{
InnerText = @"Home - Orasi Software Incorporatedhttps://www.orasi.com",
TagName = @"A"
});
link.Click();
IncogChrome.Close();
Marked as spam
Posted by (Questions: 16, Answers: 738)
Answered on March 26, 2020 2:42 pm
That's great! A very helpful example, thank you!
( at March 26, 2020 2:43 pm)