w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

How can I prevent a click event from executing the same query when the triggering link is clicked twice in a row
Declare a variable _clickFlag outside the event handler. Process the event if _clickFlag is true. Before running the query, set it to false so that consecutive clicks are not processed. In your query success callback, set _clickFlag back to true again. This method has an advantage. It won't make extra queries at all. Hope I'm clear enough. Refer to below code sample. var _clickFlag = true; $("#mainDiv").on('click', '.interested', function(event){ if (_clickFlag) {// Continue only if true _clickFlag = false; // this is to prevent other consecutive clicks to be processed when . . . interest.find({ success: function(results) { var show = Parse.Object.extend("Interested"); var int = new show(); int.set("parent

Categories : Javascript

Selenium RC skips onclick() event after click on element
Plain guess: You are using old, depreceated Selenium RC. What happens if you transfer it to webdriver approach? Sample code: WebDriver driver = new FirefoxDriver(); driver.get("http://your-test-site.com"); driver.findElement(By.id("loginForm:login")).sendKeys("login"); driver.findElement(By.id("loginForm:pass")).sendKeys("pass"); driver.findElement(By.id("loginForm:loginCmdTest").click();

Categories : Java

Click on random link in webpage using selenium API for python
How about generating a list of all available links on the page and then clicking a random element from within that list? list = driver.find_elements_by_tagname("a") list[random.Random(0, len(list)].click() (I hope that's how you use random in python 2.7, I'm a python 3.3 user, sorry)

Categories : Python

How can I have selenium (python) distinguish between similar links and click a link that changes?
There are two links in a text box? Could you clarify or show some HTML? I suggest you look at elem = driver.find_element_by_link_text("foo") to get an anchor element by the text of the link. Then click it with elem.click(). There is all sorts of good documentation for selenium with examples for a variety of languages.

Categories : Python

selenium python click on element nothing happens
Use find_element_by_id method: element = firefox.find_element_by_id("gb_23") element.click() or correct your xpath to: "//a[@id='gb_23']" Here you have nice tutorial.

Categories : Python

Selenium Webdriver, python - click 1st/2nd/3rd/etc element on a page?
read the docs, I think the function names speak for themselves. #variable "driver" is the current selenium webdriver. div = driver.find_element_by_css_selector('div.editaddress.eleven') links = div.find_elements_by_css_selector('a.add.dialogify.desktop') for link in links: #do_something

Categories : Python

PhantomJS is not able to find the element with selenium webdriver
Off the cuff, you probably are having an issue where the element loads after Selenium queries the page, and you could use waitfor.js https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js Or possibly this: driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) Or the id you are looking for is inside of a frame/iframe, in which case you would need to use Driver.SwitchTo().Frame("frameIdentifier");

Categories : Selenium

fire server click event after executing a jquery ajax call from client click event
You can use jquery trigger(): EDIT: Call the CheckApp() function from OnClientClick: <asp:imagebutton id="imgbtn" runat="server" ImageUrl="/Images/icon.gif" OnClientClick="return CheckAPP();"></asp:imagebutton> And return true or false to trigger click event: function CheckAPP() { $.ajax({ type: "POST", url: "testPage.aspx/ValidateSerialNumber", data: "{strSerialNumber:'" + strSerialNumbers + "',strManufPartNo:'" + strMPartNo + "',strCountryCode:'" + '<%=strCountryCode %>' + "',strIpAddress:'" + '<%=strIpAddress.Trim %>' + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { return true; }, failure: function (msg) { retur

Categories : Jquery

Python + Selenium + PhantomJS render to PDF
You could use selenium.selenium.capture_screenshot('file.png') but that will give you a screen shot as a png not a pdf. There does not seem to be a way to get a screenshot as a pdf. Here are the docs for capture_screenshot: http://selenium.googlecode.com/git/docs/api/py/selenium/selenium.selenium.html?highlight=screenshot#selenium.selenium.selenium.capture_screenshot

Categories : Python

Using PhantomJS with Selenium Webdriver and Python
What are you trying to achieve here? It is possible to inject javascript. So with that you could create a object that listens to the page and logs this into an object that you grab later on when you made some actions. Ill give it a try but I'm not sure what phantomJS does. browser.execute_script(" var requests= []; var received = []; var page = require('webpage').create(); page.onResourceRequested = function (request) { requests.push('Request ' + JSON.stringify(request, undefined, 4)); }; page.onResourceReceived = function (response) { received.push('Receive ' + JSON.stringify(response, undefined, 4)); }; page.open(url);"); Later (if your still on the same page) to get the requests: browser.execute_script("function(){return requests }()"); and the received connections:

Categories : Javascript

Triggering click event PhantomJS
Try this function click(el){ var ev = document.createEvent("MouseEvent"); ev.initMouseEvent( "click", true /* bubble */, true /* cancelable */, window, null, 0, 0, 0, 0, /* coordinates */ false, false, false, false, /* modifier keys */ 0 /*left*/, null ); el.dispatchEvent(ev); }

Categories : Javascript

Why isn't my Python-based Selenium PhantomJS webcrawler reaching the web?
If it is a page where you land on a page, and then it redirects you (aka, a waiting issue), then you could try wait.until(ExpectedConditions.titleIs("Google")) Note: that is Java code, but it shouldn't be too hard to convert. wait is an instance of WebDriverWait

Categories : Python

Selenium IDE not executing code angular ng-click
Have you tried using protractor? It has been developed specifically for testing end to end angularjs apps (by the angularjs team). https://github.com/angular/protractor Its like selenium on steroids (uses webdriver behind the scenes).

Categories : Angularjs

selenium.getText finds element but selenium.click does not
You are really want to use Selenium 2 (aka Web Driver), it's much more faster and reliable. So forget about Selenium 1 unless you have a really good reason to use it. Your code should look like this WebDriver driver = new FirefoxDriver(); //or any other, like ChromeDriver or OperaDriver WebElement element = driver.findElement(By.id("idOfYourElement"); element.click(); String text = element.getText(); Also see the 5 minute getting started guide

Categories : Java

Not able to click on a javascript link using selenium
Instead of the below line driver.findElement(By.partialLinkText("Change Management Console")).click(); Try this line driver.findElement(By.xpath("//a[contains(@href,'Change Management Console')]")).click();

Categories : Java

Selenium - Click Link where Text is IMG
Find the img by partial src (the filename), then go to its parent a tag. driver.find_element_by_xpath("//img[contains(@src, 'arrow-orange-right.png')]/parent::a") Equivalent xpaths (first one find the parent a, the second go to parent element directly): //img[contains(@src, 'arrow-orange-right.png')]/parent::a //img[contains(@src, 'arrow-orange-right.png')]/.. If the partial src is not unique, you may want to use full path /assets/images/icons/arrow-orange-right.png. //img[@src='/assets/images/icons/arrow-orange-right.png']/..

Categories : Python

Selenium to select and click on correct link
Try this: driver.findElement(By.id("table-id")); List<WebElement> rows = table.findElements(By.tagName("tr")); for (WebElement row : rows) { List<WebElemebt> cells = row.findElements(By.tagName("td")); if (cells[1].getText().equals("AppNameYouWantToFind")) { cells[0].click(); } } I hope you understand what's going on here but I'll describe it anyway. First, you find the table with the relevant data. Then you find each of the rows within that table, forming a list of webelemebts. For each of those rows you then create a list of all the cells. Due to your table layout you know that the App Name data is located in the second cell in your list, 'index=[1]'. So make a comparison there for the search term you want - if it matches click the proceeding cell. Th

Categories : C#

Search a link on webpage and click on it using selenium
Well...there are a couple of problems with that last set of code. The first is that you are going to get StaleElementReferences. When you find an element (or a list of elements), they are pointing to a element to a page. If you refresh the page or leave and come back, they will not be valid, and you have to re-find all of your elements. Also, many times a link doesn't navigate you to a new page. If this is the case with any of your links, you will suddenly find yourself clicking links on the wrong page (because you navigated back) Finally, you aren't actually doing anything on the page. For all you know, the link could go to a 500 Error, and Selenium would have no idea. However, since you have all of the links in a file, why not just read the file, store it in an array, and then do

Categories : File

Global click event blocks element's click event
When you click on the input, the script is working, but since the input is in the document, a click on the input is a click on the document aswell. Both function will rune, document is the last one. That is called event bubblingand you need to stop propagation : $(document).ready(function () { $(".login-input").click(function (e) { e.stopPropagation() $(this).val(""); }); }); Fiddle : http://jsfiddle.net/kLQW9/3/

Categories : Javascript

Button/Text Href link click with Selenium
execute_script fixed the issue. execute_script(script, *args) Synchronously Executes JavaScript in the current window/frame. Args : script: The JavaScript to execute. *args: Any applicable arguments for your JavaScript. Usage : driver.execute_script(‘document.title’)

Categories : Python

jQuery executing both conditions on click event
Change your condition from: if($("#s2id_author-search").css('display') === 'none'){ to: if($("#s2id_author-search").is(':visible')){

Categories : Javascript

selenium - how to click on a link based on its text using css instead of xpath and without using the contains operator?
CSS selectors do not support node selection based on their text content. Actually there was a suggestion for a pseudo class :contains which would suit your needs, but it was removed from CSS 3 spec.

Categories : CSS

How to click the DOM element in selenium webdriver thru C#
It has been fixed using Xpath. The code is below: driver.FindElement(By.XPath("//input[@value='Individual']")).Click(); Thanks to Alexander and http://www.w3schools.com/xpath/xpath_syntax.asp

Categories : C#

Disable mouse click event while executing jquery function
There is a method called promise in jQuery which can be used to check whether the animations queued have been done or not. It can used like the following the way $("div").promise().done(function() { alert("Finished!"); }); Otherwise i would suggest you to have a flag variable to check whether the animation is completed or not. and you can do the focus out to drop if the animation is not over by checking the flag variable. like the following way var animationOver = false; $(".container-inline input[type=text]").focusin(function() { $("#page-wrap").width("720px"); $("#my_search").width("171px"); $("#myDiv").animate( { width: "150px" },{queue: false, duration: 1000}); animationOver = true; }); $(".container-inline input[type=text]").focusout(function(){ if (!an

Categories : Jquery

Show/hide divs on click, but prevent the script from executing if same link is clicked a second time
A simple way to go about this: add a class to the one you just clicked, and then disallow a second click if that link is active. Codepen $('.show_hide section').click(function() { if ($(this).hasClass('active')) return false; //use if you want to allow a click after switching sections $('.active').removeClass('active'); $(this).addClass('active'); });

Categories : Jquery

Selenium WebDriver cannot click on element (works only on 1 of 2 pcs)
After trying on a few more machines, I can safely assume that the issue was with the integrated Intel HD card on the machine. It seems that selenium + javascript slideshow + intel HD

Categories : Java

How do you click on an element which is hidden using Selenium WebDriver?
You can use JavaScriptExecutor For Eg. - document.getElementsByClassName('post-tag')[0].click(); Issue that JS via JavaScriptExecutor (JavascriptExecutor(webdriver)).executeScript("document.getElementsByClassName('post-tag')[0].click();");

Categories : Python

jQuery: Understanding "event.stopPropagation()" when underlying element has click event set using "find()"
you are using delegated event registration to register the event handler, it makes use of event bubbling to register the event handlers means when an event happens in an element it will get bubbled upto all the ancestor elements till it reaches the document object. in your case when you click on a, it triggers click event for the element a, then it gets propagated to li then to ul where you have a click handler registerd it gets fired, then it reaches the body, html and last to document object where you have the other click handlers registered so those also gets executed where you are stopping the propagation but already the events attached to ul has got fired. the li handler associated with body is not fired because the propagation is prevented from the a handler in body

Categories : Jquery

unable to click on span element with .NET WebDriver but able with Selenium IDE
As Arran suggested: the problem was that the clicking occurred before the page got fully loaded (WebDriver problem) while with selenium IDE i had the application opened and loaded already so there was what to click already. so this is my stupidity) then the solution i've found is this: http://stackoverflow.com/a/16283166/1922804 i had a 'loading...' progress bar that i needed to disappear before proceeding with test execution.

Categories : C#

clicking on a link via selenium in python
You can use find_element_by_link_text: For example: link = driver.find_element_by_link_text('Details') To Click on it, just call click method: link.click()

Categories : Python

Get text from link - selenium python
Do it using CSS - .find_element_by_css_selector("li.active a"), or using xpath .find_element_by_xpath("//li[@class='active']/a") So this is how it would like finally element = self.browser.find_element_by_css_selector("li.active a") print element.text

Categories : Selenium

Not able to click on java script drop down element using selenium webdriver
You can use following methods to hover your mouse on intended menu item: el = driver.find_element(:id, "some_id") driver.action.move_to(el).perform' el = driver.find_element(:id, "some_id") driver.action.move_to(el, 100, 100).perform For more guidelines please refer this link : http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/WebDriver/ActionBuilder.html#move_to-instance_method Hope this will help you !!! Cheers...

Categories : Selenium

How to access the first element of an array and click the same at runtime using selenium web driver?
From the code you've supplied, you're using an invalid selector for the Options. They don't appear to have a name attribute Aside from modifying the loop, you could make the operation faster if the DOM isnt reconstructed. WebElement selectBox = driver.findElement(By.xpath(Testconfiguration.size_dropdown_10deep)); List<WebElement> options = selectBox.findElements(By.tagName("option")); for ( WebElement option : options ) { selectBox.click(); option.click(); }

Categories : Java

Selenium, python, clicking on a javascript link regularly?
You don't need thread to do this. Use javascript function setInterval to continuously click the link. For example: import time from selenium import webdriver driver = webdriver.Firefox() driver.get('http://jsfiddle.net/falsetru/4UxgK/show/') # Click the link every 3000 ms. driver.execute_script(''' // argument passed from Python can be accessed by `arguments` array. var link = arguments[0]; var timer = setInterval(function() { link.click(); }, 3000); ''', driver.find_element_by_id('activity')) while True: data = driver.find_element_by_id('counter').text print(data) time.sleep(1) NOTE If you get error like follow, upgrade selenium to recent version. I experienced following error with Firefox 23.0 + selenium 2.32.0. Error was gone with selenium 2

Categories : Javascript

Trigger click event without link
Just trigger the link click where you want. $(".myLink").trigger('click'); // or: $(".myLink").click(); Edit: In your question you're using the wrong handler. $("modal") would look for a <modal> element. You're looking for $('#modal'). If you want to have the dialog pop up without a link at all, you should be able to set it hidden using display: none in the CSS or style attribute, and then trigger it via code anyways. Or, you can use Fancybox for added flexibility, and they're more open about how to use their dialog boxes without attaching to a specific link, but rather any element and decide what goes inside and how to trigger it.

Categories : Javascript

Assign click-event on a new element in the event itself
Just use event Delegation $(document).on('click', '.sub', function(event){ Your click events seem to be working correctly at this point,because you are using append which actually nests the new div inside the div that is clicked. Try using after and the functionality breaks. $(function(){ var counter = 0; $(document).on('click', '.sub', function(event){ event.stopPropagation(); counter++; $div = $(this); // makes more sense in the original code $div.after('<div class="sub" title="subsub">subsub' + counter + '</div>'); }); }); Check Fiddle

Categories : Javascript

Click event not firing from href link
use preventDefault to over-ride the value you've set to the href attribute : $("a.BA").click(function(e){ e.preventDefault(); $("#boxaddform").dialog('open'); }); EDIT : After looking at your fiddle, its important that you do one more thing - initialise the dialog before calling open on it, like this : $("#boxaddform").dialog({ autoOpen: false }); You cant call open on a dialogbox which doesn't exist. Updated demo : http://jsfiddle.net/hungerpain/TrScN/8/ OR, Simply replace $("#boxaddform").dialog("open"); to $("#boxaddform").dialog(); to make it work the way it does. Demo : http://jsfiddle.net/hungerpain/TrScN/9/

Categories : Jquery

How to click links one by one with Selenium webdriver and Python
I don't know much Selenium but you should select the links again - for i in range(0,6): links = browser.find_elements_by_css_selector(MENU_LINKS_CSS_SELECTOR) links[i].click()

Categories : Python

Click on any one of "1 2 3 4 5 ..." on a page by using Selenium in Python (e.g., Splinter):
The <a> element is defined as a link. That means that you can select it by link text. I don't know Python, but the java syntax would be By.linkText(##) where ## is the number you want to click on.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.