Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

The way we test the login scenarios is after login we check anything from the next page. By anything i mean we can check :URL of the next page, Title of the next Page or an of the WebElement which is expected to appear in the second page. So once u call the login function, check if any of these thing's are present or not. I have modified your code a bit ...


0

IE has quircks with clicks, sometimes the first click is not effective and looks as if it does nothing. First I try to Click() twice on the element. If that works, it is probably a focus issue, where the first click focusses the button. Try to focus something else first. I would also try this answer.


0

Try Assert.assertFalse(message, condition) Using this the framework will not stop. Assert false will happen only when the required condition matches. example: int assetValue = 0; boolean isElementPresent; try{ isElementPresent = driver.findElement("Locator of the element").isDisplayed(); } catch (Exception e) { isElementPresent = false; } if(...


0

You can use WebDriverManager for this purpose: You can download the dependency by Gradle: dependencies { testCompile("io.github.bonigarcia:webdrivermanager:3.6.1") } Then on the code, you just need to setup the driver and create the driver objects: WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); You can find details ...


2

Drivers seems implementations of JavascriptExecutor. So it can be type casting. https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html . You could read more about this at the mentioned link


0

You can inject a factory for the behaviors you need from the packages you are importing* public interface WebFactory { public Element findElement(Locator loc); .... } The imports would be interfaces as well... public interface Element { public String getText(); ... } And then you can implement these interfaces by biding to Selenium however ...


0

Your locator would fetch the first div, of id = 100. Try the following: document.querySelector('#200 p').innerText='welcome';


0

When you land up on the page then first verify if u have landed on required page. Since u are getting no such element, it may be possible that element is not loaded by the time your code has reached to that location. So please try to add some wait before reaching to the element. it should work


0

try the below: from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0 WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, 'Department_input')))


1

Just replace your code using this may this help you: public class CommonAssertion{ public static String verifyLocationOnViewReport(){ String countryText= null; try{ // WebElement checkCarat=Driver.getDriver().findElement(By.xpath(PageUtility.SELECT_NEXT_LEVEL)); // checkCarat.click(); WebElement verifyCountry=...


3

Looking at your code, you appear to be asserting that a string and a boolean value are equal. That isn't going to work! This is what you're doing, essentially: assertEquals(true, "United States"); Either use assertTrue, or have your verifyLocationOnViewReport method return a string that you can compare to the known value.


0

There are multiple workarounds you can try: Use Headless browser or run execution in hidden mode using "phantomjs". It is driver like chrome driver which start your execution in hidden mode. Phantomjs WebSite Minimize the browser using set position in selenium. Try below code for the same: driver.manage().window().setPosition(new Point(0, -1000)); I ...


2

Most probably this occurs because of the execution speed. The code executes before loading the page. Therefore when the code looks for an element with the id='Department_input' it cant find such element and throws exception. First of all try a Thread.sleep(5000) just before where you look for the element. Thread.sleep(5000); driver....


0

So far this is the solution I have found. I did a slight change in the 3rd step. I was using intellij idea. Instead I used eclipse and created normal jar file and followed rest of the given steps. This will work. But still didn't check whether the problem with plugin I used.


0

I just checked the website "https://www.swtestacademy.com/xpath-selenium/" The following xpath should work to find the element given above. Xpath: .//span[text() = 'DEMO SITES']


0

If there is a delay between the calls to Clear and SendKeys, then this could explain your problem. Then again, you may just have to do something like this https://stackoverflow.com/questions/3249583/selenium-webdriver-i-want-to-overwrite-value-in-field-instead-of-appending-to-i I suspect that anonygoose gives a correct answer, but just like him, I cannot ...


0

This Below link is a working solution to use RobotFramework to choose date from datepicker datepicker_robotFramework


2

If you want to build so callled "fat jar" - a single executable .jar containing all dependencies and invoking TestNG main class I would recommend going for Maven Shade Plugin: Remove the following lines from your pom.xml <scope>provided</scope> Add the following Maven Shade plugin definition to create an executable jar: <plugin> <...


1

It is better to create the list and iterate through the each and every element in the list and find that if it is present list[] ele = new list[](driver.findElement("")); foreach(var elementpresent in ele) { if(elementpresent.isPresent) //or elementpresent.isDisplayed { return 1; } else { return 0: } } I hope this ...


0

You can get data from Excel using Apache POI library. Check out Busy Developers' Guide to HSSF and XSSF Features Once you get the data from Excel you can check its presence at the webpage. Not knowing the details of Excel file and the webpage structure it's impossible to come up with the code, moreover StackExchange is not a code-writing service. A wild-card ...


1

I think Kannathasan has explained the difference perfectly, but I'd like to add some context: Making the assumption that you're using Java, they're part of the Iterator interface as described here: https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html This interface is a part of Java. While it has nothing to do with Selenium-Webdriver, parts ...


0

hasNext is used to iterate the windows in selenium webdriver here is the difference hasNext() will return true if iteration has more values next() will return the next element in iteration


0

Absolute xpath: html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b Relative xpath: //*[@class='featured-box']//*[text()='Testing'] Might be the syntax you are using is wrong


0

Just as Moro suggested you are not using the correct driver instance in term and condition. Below pointers can help: remove public static WebDriver driver; from all page, business and testcase classes as you are getting it in constructor there is no need for new instance in each class In test case class use super(Driver.getDriver()) in constructor instead ...


0

anybody minds to share how to convert these 2 lines from C# to VB.NET? var wait = new WebDriverWait(unitTest.Selenium, TimeSpan.FromSeconds(timeout)); return wait.Until(driver => element); thank you very much in advance


0

This is the function I've been working on. It takes an event name and searches for it in a grid (no paging to worry about). When found, returns the row# for use elsewhere. verifyEventInGrid(eventName: string) { const names = element.all(by.className('ng-star-inserted')); names.count().then(function(count) { let rowFound = false; ...


0

Answer: use the below to hide all obstructed elements, and then send the text. Works fine (it is just invisible...which is still fine). element = driver3.find_element_by_xpath("/html/body/div[2]/form/div[2]/div/div[3]/div") driver3.execute_script("arguments[0].style.visibility='hidden'", element) element2 = driver3.find_element_by_xpath("/html/body/div[2]/...


0

You should be able to setup site-to-site vpn connection between your internal network and azure. Here is the documentation: https://docs.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-howto-site-to-site-resource-manager-portal


0

i don't know how above code is working, as there is two important things are missing. your chromedriver is outdated and you should add chromedriver path to driver build. each and every driver command executed as a promise so you need to handle them or use async await to wait for them. below code is working for me it it can help: const webdriver= require('...


0

Find profile.ini in tor directory. Copy profile.ini past to desktop. Now delete profile.ini in Tor directory. Also make sure tor browser is set to start up to a blank home page. This worked for Ubuntu Linux. Hopefully it will help windows users. Peace out.


0

Shridhar, the HTML you provided is an anchor tag. Have you tried locating the element via LinkText or PartialLinkText? Examples below: driver.findElement(By.linkText("Reports")).click(); Or: driver.findElement(By.partialLinkText("Reports")).click(); I ask because both of the options above only work with anchor tags.


0

Looks like you may want to use the javascript executor to get around the validation modifying the value inside the field between the Clear and SendKeys actions. IWebElement field = driver.FindElement(By.Id("myId")); ((IJavaScriptExecutor) driver).ExecuteScript("arguments[0].setAttribute('value', '12345')", field); Syntax not guaranteed on this, as I don't ...


0

The first thing is you have to identify that dropdown: WebElement dropdown=diver.findElement(By.name("")); List<WebElement> droplist=driver.findElements(By.tagname("option")); Then after create select class Select s=new Select(); then you can use s.selectByVisibleText("");


1

AssertTrue(true, "message") is always going to be successful as you're asking it to assert that true is true! You need the first argument of assertTrue to be something that will fail if the login was not successful, e.g. the presence of an element located on the page that appears after a successful login, but not after a failed one. E.g. loginBusiness....


0

Finally it turned out to be a xpath problem. I changed xpath of driver.findElement(By.xpath("//li/div[5]")).sendKeys("Overnight"); to driver.findElement(By.xpath("//li/div[5]/div[3]/div[1]")).sendKeys("Overnight"); now it works


0

Go to your conf.js file and create an onPrepare function, there you can define and initialize a global variable. Below is a sample: exports.config = { directConnect: true, capabilities: { 'browserName': 'chrome' }, framework: 'jasmine', baseUrl: "http://url.com", specs: ['./*_specs.js'], ...


0

This is a web element in itself, write xpath for this button element and perform your action: webElement submitBtn = driver.findElement(by.xpath("//button[@type='submit']")); submitBtn.click(); To know more about 'how to create xpath' watch this video tutorial: https://www.youtube.com/watch?v=67bzMdbhIuw


0

May this help you, just replace your test case class like this:- public class MhCurrentMonthReportTest extends LoginTest { public MhCurrentMonthReportBusiness mhCurrentMonthReportBusiness; public MhCurrentMonthReportTest() throws Exception { mhCurrentMonthReportBusiness = PageFactory.initElements(driver, ...


1

You're on the right track, but I've only recently discovered myself the solution to this type of problem. Surround the main xpath with parenthesis, place the subscript AFTER. Assuming that your basic xpath is correct, the following should isolate element 1: (//span[@class='cursor']//*[local-name()='svg'][@class='excel-document'])[1]


0

Refer the following article. Note: Use ${asset} without double quotes


0

ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tabs.get(1)); driver.close(); driver.switchTo().window(tabs.get2));


-1

You can ask for a link tag which contains some substring in its onmouseover attribute. //a[contains(@onmouseover, '338792')]


3

You need to get the innerHTML via getAttribute("onmouseover") function and parse the String using a regular expression. There is no direct approach from Selenium.


2

You need to capture a List of elements. Then the first row will be the first element of the list and so on. Your html structure makes it quite simple, so for the field elements it would be: IList<IWebElement> fields = driver.FindElements(By.CssSelector("table[id='advFilter'] td[class='field'] div[class='apidrop apidicon']")); fields[0].Click(); The ...


1

So for me, once we have a change committed for a single module and manual testing has been completed, I would first run/trigger the smoke tests and then will trigger the in-depth tests related to that module only. Yes, regression would still run the entire test suite (based on the trigger - daily/weekly etc.) irrespective of the changes because that's what ...


1

Under "NONE OF THESE WORK" you have 4 examples. Here I'll try to explain why they don't work. Actions is not defined This happens because the driver object has a method actions(), not Actions member (unlike Selenium Java). Also, your callback function in .then is missing the argument that will contain the found element. So instead you you could use: ...


0

(c) clearly breaks the Single Responsibility Principle (SRP) (a) would result in duplicated code, which is solved by (b). A few other things you can do would depend on how you control the environment. You can have different login page objects for each user type, which implement the method login returning the user-specific main page. This way, you replace a ...


1

Putting aside all the general test automation wisdom, in this specific scenario I would suggest it's not worth it. Reasons It is reverting back code to an specific case from an generalized Abtracted code. I have found labels/text are actually more static over time compared to internal object properties. In both cases ,definition of element is local ...


2

First of all, I am new to the testing environment. My client wants the same solution. He wants to reduce the testing time which is currently 4 hours. I am in the learning phase. Here is the detail of how I achieved that. I asked testers to divide the test cases into 5 subsets. It means 5 different pom files & test cases for each. I used the selenium ...


0

//*[@id='nav']/li[1]/a[contains(@title, 'List of Users'] You missed ')' at the last ']', it should be like below: //*[@id='nav']/li[1]/a[contains(@title, 'List of Users')]


Top 50 recent answers are included