Is there a way to click on a hidden value in a sub menu. I would like to be able to do something like
driver.findElement(protractor.By.xpath('/html/body/div/div/a')).mouseover.then(function() {
ptor.findElement(protractor.By.className('name').getText().then(function(result) {
expect(result).toBe('Me');
});
});
when the menu item is not visible, or are we limited with this at the moment. If this is not possible is there a way around this issue at present.
perform(); ptor. element. all(by. tagName('i')).
In case an element is a part of the form tag, it can be hidden by setting the attribute type to the value hidden. Selenium by default cannot handle hidden elements and throws ElementNotVisibleException while working with them. Javascript Executor is used to handle hidden elements on the page.
Protractor – As discussed earlier, it is a wrapper over WebDriver JS especially designed for angular apps. Jasmine – A behavior-driven development framework for testing the JavaScript code. We can write the tests easily with Jasmine. WebDriver JS – A Node JS binding implementation for Selenium 2.0/WebDriver.
Protractor supports Angular-specific locator strategies, which allows you to test Angular-specific elements without any additional setup effort.
ok so after a long and painful search trying to find an answer to this question I finally came across the answer trying to answer a different question.
Most of the documentation I found explain that we must use Actions in the form of a WebElement and then cast that to Javascript and pass it a script element in the form of an array with the click action.
Well the same kinds goes here but with a few modifications.
describe('', function() {
var ptor = protractor.getInstance();
var driver = ptor.driver;
it('', function() {
var hiddenElement = driver.findElement(protractor.By.yourchosenlocator(''));
driver.executeScript("arguments[0].click()", hiddenElement).then(function() {
expect(whatever).toMatch(whatever);
});
}, 30000);
});
as you can see there is no use of webelement and no cast required.
Here are the sources that helped me in my search for answers
How do you click on an element which is hidden using Selenium Webdriver?
SELENIUM WEBDRIVER – HOW TO CLICK ON A HIDDEN LINK OR MENU
Selenium WebDriver - hidden select and anchor [duplicate]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With