Protractor “by.css()” vs “$()” Dollar Sign vs “$$()” ‘Bling Bling’

$ and $$ are just convenient shortcuts. $(“selector”) is an alternative for element(by.css(“selector”)). $$(“selector”) is an alternative for element.all(by.css(“selector”)). FYI, quote from the source code: ElementFinder.prototype.$ = function(selector) { return this.element(webdriver.By.css(selector)); }; ElementArrayFinder.prototype.$$ = function(selector) { return this.all(webdriver.By.css(selector)); }; And the actual commit that initially made it happen.

Running Selenium scripts with JMeter

Below are possible ways to run Selenium test-cases from JMeter: using JUnit Request Sampler; using BeanShell Sampler; using JSR223 Sampler + Groovy. JUnit Request Sampler Running Selenium tests this way maybe useful if you want to re-use already automated (Java) Selenium scenarios instead of re-writing JS-scripts for WebDriver Sampler. Selenium RC Prepare Selenium test project … Read more

How to automate shadow DOM elements using selenium?

There is a very good plugin that can be used with selenium project shadow-automation-selenium. It helps in writing much better, readable and maintainable code. Using this you can access multi level of shadow DOM (up to 4 levels). This uses simple css selector to identify elements. WebElement findElement(String cssSelector) : use this method if want … Read more

How can selenium web driver get to know when the new window has opened and then resume its execution

You need to switch the control to pop-up window before doing any operations in it. By using this you can solve your problem. Before opening the popup window get the handle of main window and save it. String mwh=driver.getWindowHandle(); Now try to open the popup window by performing some action: driver.findElement(By.xpath(“”)).click(); Set s=driver.getWindowHandles(); //this method … Read more

JavaScript simulate right click through code

try this instead, reason what things didn’t quite work is that the context menu is in fact bound to the oncontextmenu event. function contextMenuClick(element){ var evt = element.ownerDocument.createEvent(‘MouseEvents’); var RIGHT_CLICK_BUTTON_CODE = 2; // the same for FF and IE evt.initMouseEvent(‘contextmenu’, true, true, element.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, RIGHT_CLICK_BUTTON_CODE, null); if … Read more

How to get entered text from a textbox in Selenium

The getText() method is for retrieving a text node between element tags for example: <p>Something</p> getText() will return “Something” In a textbox typed text goes into the value attribute so you can try something like: findElement(By.id(“someid”)).getAttribute(“value”); ComboBox is a bit different. But if you’re using the Select object you can use the method: Select selectItem … Read more

How to write multiple conditions of if-statement in Robot Framework

You should use small caps “or” and “and” instead of OR and AND. And beware also the spaces/tabs between keywords and arguments (you need at least two spaces). Here is a code sample with your three keywords working fine: Here is the file ts.txt: *** test cases *** mytest ${color} = set variable Red Run … Read more