VB.NET - Invoke ContextMenu Item Click Programatically for WebBrowser control - vb.net

I am having a WebBrowser control and loaded a local image into an IMG tag and set the DocumentText of the WebBrowser as below
<!DOCTYPE HTML>
<meta http-equiv='X-UA-Compatible' content='IE=10' />
<html lang='en'>
<body style='margin: 0; overflow: hidden;'>
<img Width = 1269 Height = 1600 src='C:\Users\ADMIN\Desktop\p41.png'></img>
</body>
</html>
It is loading perfectly fine. For some reason, I want to invoke the context menu of the image and click one of the context menu items programmatically (say for example "Copy" - though I don't want this - I can choose any item in the menu). I don't know how to achieve this. When I tried to iterate the context menu of the browser control, I am getting System.NullReferenceException: 'Object reference not set to an instance of an object.' as I have not placed any ContextMenu control in the form, since I wanted to access the WebBrowser's inbuilt context menu. Is this achievable ?
Or is there a way to get the code (which IE does) for each of its menu item, so I can directly call that - atleast for "Save picture as..." and "Copy"
Please Note: I do not want to use the "SRC" attribute to be part of any solution as I do not want that as you see I am the one forming the HTML tag with that. Hence I know that.
Please find the screenshot below

Related

Selenium VBA Unable to Click Checkbox

Using Selenium and Chrome, I'm attempting to check a box located within a table. The table contains 2 checkboxes but they act as radio buttons, in that if I click one, the other will uncheck.
I've tried a variety of methods, which include the following:
Const CHECKED_STATE As String = "Ag-icon ag-icon-checkbox-checked"
findElementByClassName("ag-selection-checkbox").fireEvent("CHECKED_STATE")
findElementbyXPath("//span[#class=ag-icon ag-icon-checkbox-checked'])[1]").Click
findElementbyXPath(".//div[#class='ag-body-container']").Click
I'm not sure how to click the checkbox when the HTML code doesn't even have a checkbox type or an Id.
The HTML reads:
<span class="ag-icon-checkbox">
<span class = "ag-icon ag-icon checkbox-checked ag-hidden">
<span class = "ag-icon ag-icon checkbox-unchecked">
<span class = "ag-icon ag-icon checkbox-undeterminate ag-hidden"></span>
When I click on the checkbox, the unchecked and hidden lines of HTML will flip. So I'm guessing it's some sort of event that I have to trigger.
The following, depending on the rest of the html, should work to select the unchecked item and thereby toggle off the other item. It targets the class checkbox-unchecked:
driver.FindElementByCss(".ag-icon-checkbox .checkbox-unchecked").click

I want a 'Text Field' in a folder that is within a document library - Sharepoint 2010

I am rather new to sharepoint and have been lucky enough to find the answer to all my questions with research. I have no found the answer to this question yet.... How do I add a text field WITHIN a folder that is WITHIN a document library. Example: I want to put instructions for upload within a specific folder. I tried to to the 'edit page' --> add text, but the text shows up at the top of ALL folders within that library and I just want it in one. Thank you for your assistance!
Kind regards,
Lanie
You can manage visibility of your message using JavaScript as below.
Don't directly add your message in text field; instead click of the text field you have added, and click "Edit HTML Source" in ribbon bar as highlighted in below image.
Then paste below code in newly opened window:
(Don't forget to replace "Your Message" and "FolderNameInWhichMessageToBeShown" in below code)
<div id="MyCustomMessage">
Your Message
</div>
<script type="text/javascript">
if(decodeURIComponent(document.URL).indexOf('FolderNameInWhichMessageToBeShown') == -1)
{
document.getElementById('MyCustomMessage').style.display = 'none'
}
else
{
document.getElementById('MyCustomMessage').style.display = 'block'
}
</script>
Click "OK" and Save your page.

Dojo Cannot set href then select ContentPane in AccordionContainer

I have two ContentPanes inside an AccordionView. When a button is clicked on the first one I want to set the href on the second one and then set it as selected. To do this I run this code:
searchResultsContentPane.set("href", "modules/content_panes/test_module.html");
searchAccordionContainer.selectChild(searchResultsContentPane, true);
For some reason though the ContentPane will animate it halfway opening and then it will just pop closed with nothing loaded into it.
Here is the ContentPane declaration:
<!-- Search Results Accordian View -->
<div class="searchAccordianPane" id="searchResultsContentPane" title="Search Results" dojoType="dijit.layout.ContentPane" data-dojo-props='refreshOnShow:true'></div>
If I set the href inside the declartion as a data-dojo-props value it will show it but eventually I will need to add GET values to the URL so I can't have it static.
Thanks for the help

How do I automatically select the first panel in a declarative dojo wizard?

I have created a declarative dojo wizard in dojo 1.5 that is embedded in a dojo dialog like this:
<div dojoType="dijit.Dialog" id="genWizardDialog" jsId="genWizardDialog" refreshOnShow="true" preventCache="true" title="Title">
<div dojoType="dojox.widget.Wizard" style='height: 375px; width:400px' hideDisabled="true" doneButtonLabel="someLabel">
<div id="wizard1" dojoType="dojox.widget.WizardPane" canGoBack="false" passFunction="panelOneDriver"></div>
<div id="wizard2" dojoType="dojox.widget.WizardPane" passFunction="validateBoxes" style="padding:8px; height:100%;"></div>
....I have some more panels.
</div>
<!-- Here I have setup the cancel method. -->
<script type="dojo/method" event="cancelFunction">
//dijit.byId("genWizardDialog").onSelected(0);
dijit.byId("genWizardDialog").hide();
</script>
</div>
Everything pretty much works. However, I have 4 panels. If I proceed to panel three and hit cancel. When I then click the button to start the dojo dialog I am already at panel 3! I want to start back at panel 1. As I have already invested time into the declarative approach I am hoping to avoid doing this programmatically. I found site that mentioned an onSelected() method to accomplish this -> http://dojo-toolkit.33424.n3.nabble.com/resetting-wizard-pane-and-contents-on-reopening-wizard-td158660.html, however, this didn't work and stands to reason since looking in the Wizard.js I don't see this method defined!
In your pasted code, you have the cancelFunction event in the dialog's div, not the wizard's. So move the <script> tag inside the div that has dojoType=dojox.widget.Wizard.
To select a specific wizard pane, you can use the selectChild function.
<script type="dojo/method" event="cancelFunction">
dijit.byId("genWizardDialog").hide();
dijit.byId("genWizard").selectChild("wizard1", false);
</script>
In the above, I've assumed that your wizard has an id "genWizard", so you'd have to add that to the wizard's div.
Now the wizard will jump to the first wizard pane when you click its cancel button.
It will not jump to the first wizard pane if you just click the dialog's X button. If you want that too, you need to use the dialog's onHide event.
<script type="dojo/method" event="onHide">
dijit.byId("genWizard").selectChild("wizard1", false);
</script>
This script tag has to be in the dialog's div, not the wizard's, make sure you get that right.

how can I add event to richfaces fileUpload "on clear"

there are clear, clear all buttons on richfaces fileUpload component.
<rich:fileUpload id="quoteFile" tabindex="10" listHeight="80" maxFilesQuantity="1" onuploadcanceled=""
clearControlLabel=""
clearAllControlLabel=""
acceptedTypes="xml"
fileUploadListener="#{loadSaveQuotes.uploadListener}">
<a4j:support event="onuploadcanceled" action="#{loadSaveQuotes.clearUploadData}" reRender="footer" />
</rich:fileUpload>
all I want to are:
1, remove the both buttons so that end user cannot click it. as I set clearControlLabel to "", and clearAllControlLabel to "", but only clearControlLabel is hidden. still have clear All Control appear as [x] button and I still click it
2, if I cannot remove these button, so how do I take control of them. like add an event listener to that on clear event. I added an a4j:support event but it do not trigger when I click clear button.
many thanks for your contribute.
Add an a4j:support for 'onclear' JavaScript event. The code is self-explanatory:
<rich:fileUpload id="upload">
<a4j:support event="onclear" reRender="upload"/>
</rich:fileUpload>
You can hide these buttons through CSS, e.g. you can give your fileupload an additional class like
<rich:fileUpload styleClass="my-upload"> etc. </rich:fileUpload>
and then use CSS Specificity to overrule the appearance of this fileupload component:
.my-upload .rf-fu-btns-rgh, .my-upload .rf-fu-itm-rgh {
display: none;
}
You can choose any combination of selectors that has higher specificity then the original one from RichFaces. I find having an extra class the cleanest solution, as it would allow me to have "normal" and "modified" RichFaces components next to each other, only differing in their style class.
You can look up the RichFaces style classes of the elements you want to alter in the RichFaces component documentation or with your favourite website inspection tool.
I was having the same requirement. Hide Clear All button and Clear Link but only when the file is submitted for upload. I solved this requirement with dynamic css through JavaScript. Below is the example.
rich:fileUpload control
<rich:fileUpload id="excelUploader"
fileUploadListener="#{uploadUIController.excelFileUploadListener}"
acceptedTypes=".xls"
maxFilesQuantity="1"
noDuplicate="true"
ontyperejected="Wrong file type selected !"
serverErrorLabel="Invalid file type selected !"
listHeight="100px"
doneLabel="Excel Upload Completed !"
onfilesubmit="showHideClearLink()"
styleClass="fileUploadClass"/>
Javascript code at the top of the file...
<script type="text/javascript">
function showHideClearLink()
{
var styleSheet = document.createElement('style')
styleSheet.innerHTML = ".fileUploadClass .rf-fu-btns-rgh, .fileUploadClass .rf-fu-itm-rgh {display: none;}";
document.body.appendChild(styleSheet);
}