I'm working on MSTest framework where the window based app is automated using selenium with .net C#.
I have a scenario to automate where all the options (tab, text or button etc) present on windows app are greyed out. So, when a user try to click on any of those option nothing should happen.
I thought to take the locator of any these option and put a bool condition to see if an app refresh or not, when user try to click on greyed out option. But I am not able to think well how to do so as I'm not good in coding :(
I took the AccessibilityId (locator) of the option (eg: Tab) and observe that in debug mode that WindowsApplicationDrive is returning Element in id form to the variable. So, now I don't know how to use the bool condition to validate this.
Any example help would be appreciated which I can relate and try to test the above scenario.
You can verify the buttons etc attributes - for instance if button is set to Disabled. Inspect the button when 'greyed out' and see what is set.
Related
i have work on an app that manipulate some application context menue to extend its functions, i have checked all the common posts here on stackOverFlow on how to manipulate the menu context using Windows api in C# using functions like GetMenu(...), InsertMenuItem(...), ShowOwnedPopups(...) and that comes in vain, here is the scenario, the application i wanna manipulate it context menu has many context menus in many parts but i want to manipulate certain one which belongs to the viewer part. so i have used spy++ to figure the the handle of the viewer and a send a message WM_CONTEXTMENU using SendMessage(...) function. the menu finally appears and i have its handle.
i guess after i get the handle it would be constant for the life time of the program for the single running time, but i figured out that the handle is changing every single time a i have clicked right click. and the parent of the context menu isn't the viewer area itself but the desktop that's was disappointing.
so i have two problems
1- i can't get the handle directly as using GetMenu(...) passing the handle of the viewer returns null, after some search if found that the context menu has a class name of "#32768" so i have filtered all the open windows to get the one that its class name equlas "#32768". and now i can access the handle from my c# code not from the spy. but here is an comming issue: if there is a sub menue.. it also have the same class and unfortunately this is totally logical :/
2- i can't get the context handle before it is shown and if it is shown, i can't manipulate it as i know. The second thing is that the context handle continuously changes every single time i right click the mouse. so i can't pass the first time i click then save the handle for the next clicks to make it work.
any suggestion are very welcomed.
First of all you should figure out if you can just send it a WM_COMMAND message to perform your command. A context menu might not use that message but if the application also has a normal menu then it is likely that it will handle the message. Note that the command id might change between program versions.
All Win32 HMENU menus use the same class and MN_GETHMENU is the only related documented message.
The recommended solution is to use UI Automation/MSAA to navigate the UI of other applications.
I just want to test my code in multiple browsers at the same time, instead of right clicking on the aspx then clicking browse with... It's kinda frustrating me since my boss wants me to be fast always.
and please don't suggest copying the url then pasting it to the browser, because I already know that...
It is indeed possible, here is a link to a simple guide that was designed for VS 2013 but should track up to 2017, find it here.
Here are the important bits:
When you select the “Browse With…” option, following dialog will
appear, and you can see all the list of browser along with the browser
which marked as “(Default)”.
Now, there can be more than one default browser, and same has been
written in the dialog control as well – “Browsers (Select one or
more):” . So, select all the browser in which you want run the
application together, and click on “Set as Default”. That’s all. Now
if you click on “Browse” button in the same dialog control, you will
find your web application starts on all the selected browser same
time.
This presents you with a 'multiple browsers' option for debugging.
Note:
As per Raniels comment below:
visual studio 2010, I just pressed crtl + click browsers that I want
to set as default.
I'm trying to log into a website and use Selenium to take a screenshot through code. So far, it's been working great except for one problem: every time I access the website, both manually and with Selenium, a popup asks me to confirm a security certificate.
The certificate is good, but I cannot for the life of me get Selenium to accept the window. I know it can deal with Alerts and accept them thusly:
driver.Navigate().GoToUrl("https://www.securewebsite.com");
driver.SwitchTo().Alert().Accept();
but the box doesn't disappear or react, and attempting to do anything with the driver besides accepting or declining the alert (with no effect) results in a Modal Dialog Present error.
I'm looking for either a way to turn off this popup or a way for Selenium to deal with it in code, preferably the latter. Let me know if I can provide any more information.
Alright, I couldn't figure it out, so I just disabled the popup. It's poor practice and binding the application to the specific instance of IE, but it was all I could come up with.
I am using __doPostback of a button control and it will take some time to complete the db operations. I am using it in an update panel and I am getting an issue from IE that it will say
Stop running this script.
May I know what is the issue ?
I think it may be due to __doPostBack. Previously it is direclty calling the Click Event. Thanks in advance.
Check your User Agent string. This same thing happened to me one time and I realized it was because I was testing out some pages as "googlebot". The JavaScript that is generated depends on knowing what the user agent is.
From http://support.mozilla.com/tiki-view_forum_thread.php?locale=tr&comments_parentId=160492&forumId=1:
To reset your user agent string type about:config into the location
bar and press enter. This brings up a list of preferences. Enter
general.useragent into the filter box, this should show a few
preferences (probably 4 of them). If any have the status user set,
right-click on the preference and choose Reset
Avoiding the 'Script taking too long' (all browsers have some form or another of this) message in browsers is relatively simple. You just have to make sure the browser knows you have not created an endless loop or recursion. And the easiest way to do is is to just give the browser a breather in between long running tasks.
have a look at this solution
http://www.picnet.com.au/blogs/Guido/post/2010/03/04/How-to-prevent-Stop-running-this-script-message-in-browsers
I'm developing an addon for IE8+.
Main function:
- when I click the toolbar, it will display a box inside every single page, ex: google.com, bing.com, codeproject.com... by using execScript to execute jQuery.
Therefore, what Im doing is run javascript in the current page.
Everything has done except when that page perform an Pop-up, it doesnt work anymore.
I click the toolbar, nothing happen, but when I look at the pop-up, surprise! has the box which im trying to display. So, I think the current tab and the popup of its is running the same process.
I have change registry key TabProcGrowth to 20, to make sure every single tab run by its own process, but maybe it not work with popup.
sr for my bad english, any suggestion is welcome.
Thanks in advance.
update:
I have changed the way to develop my addon, so I change my question, too. (But any suggestion for the 1st question still very useful for me).
My new question still mention the "execScript" problem.
HOW to execute javascript with every individual tab of IE browser with TabProcGrowth = 0. I need this value set to 0 because I have the timer to request to the server every interval1 (ex: 60s). So if there are more than one processes of IE, the addon will send multi request to server at the sametime.
In my situation now, I set TabProcGrowth to 0. Open IE, open some tabs. Click the toolbar at the newest tab, it works, ofcourse!. But when I click toolbar at the old one, nothing happen. The script still be execute but it takes effect on the newest tab.
It's the big problem for me, resolve this problem, you guys save my life.