So basically I want to press a button in a website and i dont know what code to use. The HTML line looks like this:
Click Here
I want the program to click on that Free Button using DOM. I tried this :
webBrowser1.Document.GetElementByClassName("free").InvokeMember("click");
But for some reason the GetElementByClassName is highlighted (in visual studio 2015)
I cannot change the HTML since the website is not mine.
It's highlighted cause there is no function GetElementByClassName in WebBrowser.Document!
Look at this, maybe it would help you:
How to select a class by GetElementByClass and click on it programmically
Related
I just try to write correct path to click exactly this button what I want on my page. I will give you an example page for testing. You just have to download the HTML file and open it in your browser.Code of HTML page
What we now want to do?
If you run this HTML file you will see all page.
And now we want to make a Click on exactly this button on screen :
After when you click on this button you will see click counter below: like this :
Have anyone idea how to click it? I tried few ways and can't find solution still. Please help.
I try at least :
drive.FindElement(By.XPath("//tr[class='ng-scope']/td[text()='Wylaczenie nadan RDF'] and button[#title='Skip']")).Click();
and
drive.FindElement(By.XPath("//tr[text()='Wylaczenie nadan RDF']/button[#title='Skip']")).Click();
+ more and more and can't just write fine this Path to click exacly this button.
And unique value is <td class="ng-binding">Wylaczenie nadan RDF</td> - i prefer to get path by this.
You need to use below XPATH for the same
//tr[td='Wylaczenie nadan RDF']//button[#title='Skip']"
//tr[td='Wylaczenie nadan RDF'] will take you to the row which contains that text and then you use //button[#title='Skip'] to find that button
Actually, I am have designed an application using WindowsUI(MetroUI) with TileContainers.
Now,My problem is that : I have a text in TextBox and I have selected the text and want to copy it with mouse right click other than ctrl+c.(Because my clients are not aware of the shortcuts).
So,When I'm rightclicking on the textbox with mouse,the TileContainer WindowsUIButtons are sliding from top of the page.
Is there any chance of getting that?
sorry for my bad english :)
If I understand your question correctly then you could just use a Context Menu.
See this URL for a step by step process on doing exactly what it sounds like you are wanting.
Hope this helps.
I am writing Coded UI Test's for a web app. I am having problems such as I record actions using the test builder, however sometimes the button that is clicked has different information each time I run the test and as result VS can't find the button.
The html code never changes so what I want to do is find the button by its html code and click it that way.
For example on Google the path to the search button is
<button id="gbqfba" aria-label="Google Search" name="btnK" class="gbqfba"><span id="gbqfsa">Google Search</span></button>
How can I click this button using the code above or Alternativly using the XPath
//*[#id="gbqfba"]
Any help would be greatly appreciated.
adjust the Search Properties and Filter Properties.
Something like:
$('button span').each(function(){
If($(this).html() == "Google Search")
{
$(this).parent('button').click();
}
});
I found the answer, If you go to the UIMap.uitest file and click the method you have the problem with you can change the filter properties and the search properties to remove parts that are failing your test.
This will do the trick:
BrowserWindow.ExecuteScript("$('#gbqfba').click();");
I am trying to make a button that when clicked call a procedure but also opens in a pop-up. I can't find how to do it because all the search i did only tells me to put it on te clientclick :
<asp:Button ID="cmbGen" runat="server" Width="240px" Text="Générer le rapport" OnClick="cmbGen_Click"></asp:Button>
the onclick opens up a pdf, and its not working well on Ie, so, to solve this i would like the pdf to opens in a pop up
not sure what i could do.. anyone got an idea ?
EDIT
The code is pretty big, but basicaly, depending on what checkboxed were checked, it will create a pdf file and show it. this works pretty well, but it opens up in the current page, i would like to make it in a pop-up
A Button always submits a postback to the server on the current window, so you can't directly tie a new window to it. You'll need to write some javascript to do that, and open a popup window.
You can do this lots of ways - you can hook up an event handler to the button so when it's clicked, it immediately opens a new window, and that window is pointed to your server code which returns the PDF. Or you can do a regular postback, and return some javascript that pops up a new window. But either way, javascript is the only way to get a popup from a form button.
Liam's suggestion of making a link instead of a button is probably the simplest method - you can throw an image on that link to make it look like a button if you want.
EDIT
Based on your comment on the other answer, your simplest bet would be to return some javascript on the button click method, using ClientScript.RegisterStartupScript or whatever Microsoft is recommending these days. You can do whatever logic you need to first, then get that into a new handler either through session or querystring parameters, and have the client pop up a new window pointing to that handler.
Can't see you c# so it's not 100% sure what you want but why use a asp:Button at all:
Générer le rapport
I'm just using watin to fill some textfields but sometimes it writes in the wrong textfield because the textfields name is not clear here's my code
IE browser = new IE(site);
browser.TextField(Find.By("type","text")).TypeTextQuickly(username.ToString());
browser.TextField(Find.By("type", //"password")).TypeTextQuickly(pass.ToString());
browser.Button(Find.By("type", "submit")).Click();
Edit your HTML code and setup ID´s for your input elements. Then use Find.ById
One option could be to see if there is an outer element (such as a Div) you can find first, and afterwards get the text fields from that element instead of from the browser variable. That could for instance look like this:
Div div = browser.Div(Find.ById("divId"));
//Div div = browser.Div(Find.ByClass("divClass")); // or like this for instance...
TextField text = div.TextField(Find.By("type", "text"));
TextField password = div.TextField(Find.By("type", "password"));
Button submit = div.Button(Find.By("type", "submit"));
I am unclear as to your knowledge of WatiN and testing so I will start from the begginging. First you need to go on the webpage you want to test and (in IE) go to tools -> Developer tools. Click the white arrow in the menu then proceed to click the box you wish to utilize. Once you do this the developer tools will give you the code for the textbox including many ways you can reference it in your code. For example, using dev tools in IE I can automate logging into my gmail like this:
IE browser = new IE("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1<mpl=default<mplcache=2");
browser.TextField(Find.ByID("Email")).TypeText("myemail#email.com");
browser.TextField(Find.ByID("Passwd")).TypeText("mypassword");
browser.Button(Find.ByID("signIn")).Click();
There are many Find.By commands so there is no reason you can't acess ANY textfield you wish. You just need the html and to be specific to which one you want to write into. I hope this helps :)