New answers tagged

0

public void loginToStrata(String email,String psw) throws InterruptedException { enterEmail(email); enterPassword(psw); clickLogin(); Thread.sleep(1000); List<WebElement> emailErrorPresence=driver.findElements(emailError); List<WebElement> pswErrorPresence=driver.findElements(pswError); if(...


0

I used both of the tools and I would see if you have a huge product with lots of advanced and difficult situations, then use protractor, otherwise use cypress. Both tools work great!


0

Cross Browser testing has a become a vital part of any automation and a good QA company will always use this logic in their automation frameworks. If you have implemented Chrome in your framework, then there are 02 ways using which you can execute your scripts on other browsers - Option 1: Update your existing 'Webriver load method' with the code to load IE ...


1

Write a helper method TryFindElement that doesn't throw an exception but returns false if it isn't found? Here's my C# example: public bool TryFindElement(By locator) { try { driver.FindElement(locator); return true; } catch (NoSuchElementException) { return false; } catch (TargetInvocationException) { ...


0

Below is an example on how to get the text of tool tip: driver.get("file:///C:/Users/prave/Desktop/push.html"); Actions builder = new Actions(driver); builder.moveToElement(driver.findElement(By.className("tooltip"))).build().perform(); WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); WebElement ...


0

There is no write way of writing page object class: This is from selenium : https://www.selenium.dev/documentation/en/guidelines_and_recommendations/page_object_models/ There is a lot of flexibility in how the page objects may be designed, but there are a few basic rules for getting the desired maintainability of your test code. Page objects themselves ...


0

WebDriverWait(driver,30).until(EC.element_to_be_clickable((By.CLASS_NAME,"k-input"))).click() WebDriverWait(driver,30).until(EC.visibility_of_element_located((By.XPATH,"//span[contain(text(),'2 years')]"))).click() Try using wait, and if second line doesn't work use below code click the parent span tag instead WebDriverWait(driver,30)....


0

when ever you want to find an element uniquely , and that element doesn't have a unique attribute then find a parent that has an unique attribute and use it as referrence In your case the div tag is the referrence , if you want second drop down use: product_id_box = driver.find_element_by_xpath('//div[@class="Site-secondary"]//*[@id="productid&...


0

I don't think it is the best practice to pass your web-Driver as a parameter and pass it to every single method. Don't create method for returning the web-Elements , Instead Use PageFactory or your By class at the top of your page class . If possible separate your webElement from your page , Keep them in Some separate file. SO in Future if your WebElement ...


0

I can find the difference , If you want to use the 2nd drop-down. Use the header tag else everything looks same. So try to create the dynamic x-path something like //*[@text="Variable Product Performance"]//following::Select[1] Try this maybe this helps...


0

In its current format, I think forming an xpath locator is probably your best bet. However, the 2 dropdowns, as you say, have the same name and id. I think I'd raise this as a bug - ids are generally meant to be unique at the very least. If nothing else, it's made your automated test creation effort that much harder - testability is a measure of how easy the ...


0

you can find a element as elem = driver.findElement(somelocator) or elem.findElement(someLocator) Now consider a use case where you have to find all options inside a header here the header locator is: //ol[@role="presentation"] Now as the icon are children of the header element and header element is unique , we can use this as reference to find ...


0

driver.get("https://catevolution.com.au/litter-robot-iii-open-air.html") driver.maximize_window() action = ActionChains(driver) #menu elem = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.XPATH, '//header//strong[contains(text(),"Litter Robot")]'))) action = ActionChains(driver) # perform the operation action....


0

Assuming you have a pagebject method pageObject.selectCheckbox(idx) which select a checkbox using index. and pageObject.verify("Message") which takes in the expected message and verifies its present. let final = [] printCombination = function (arr, n, r) { data = Array(r) combinationUtil(arr, data, 0, n - 1, 0, r) } combinationUtil = ...


1

for(int i=1; i<sections.size()+1; i++) Why are you adding 1 to sections size, remove 1 for(int i=1; i<sections.size(); i++) and also why starting from i=1 ? index starts from 0 to size-1 , so it should be i=0 ?


0

you are using driver.execute_script("document.body.scrollTo(0, -350);" scrollTO will scroll to specified pixel positon , it is a one time operation as the body lenght and width remains the same. IF you want to scroll continously use : ScrollBy driver.execute_script("document.body.scrollBy(0, 350);" #down driver.execute_script("...


0

In the Java code you are using .scrollBy() but in your python code you are using .scrollTo(). My guess is that it is not scrolling because of this mixup. Try changing the python code to use .scrollBy() method


0

try using Actions class : Actions action=new Actions(driver); action.moveToElement(utilityTopUp).bulid().perform(); action.moveToElement(utilityTopUp).click().build().perform();


1

Update use: //*[text()[contains(.,"Utility Top Up")]] use wait : wait.until(ExpectedConditions.presenceOfElementLocated​(By.xpath("//*[text()[contains(.,"Utility Top Up")]]"))); The text is inside anchor tag but there is a tag in between text so , first get text contents using text() and check for utility Top in all the ...


1

You have twice the same selector: By.xpath("//div[@id='wrapper']/div/ul/li[9]/a") Are you sure the second time the selector is exact the same? In my experience new elements that are created after a click have a different selector. I would try a more simple selector like: By.partialLinkText("Utility Top Up") If you want a better answer I ...


0

I would also suggest to make it less messy: Make few generic db connection/retrieval functions if data retrieval is not dynamic , create separate script to populate a data source like an file: json, csv or excel to further use directly in simpler way in tests.


0

To select the element with text as Constants.INBOUNDORDER_CUSTOMER as the element is a Angular element you need to induce WebDriverWait for the elementToBeClickable() and you can use the following Locator Strategies: List<WebElement> options = select.findElements(By.xpath("//div[@class= 'mat-autocomplete-panel ng-star-inserted mat-autocomplete-...


2

driver.findElement(By.name("pincode")).sendKeys(rs.getString(1)); Is this what you looking for


1

Mobile and windows screen will have different size , I checked the page and it seems the height is larger in mobile screen try using jaa.executeScript("document.body.scrollBy(0,350);", "");


-1

For Python - import chromedriver_autoinstaller from selenium import webdriver opt = webdriver.ChromeOptions() opt.add_argument("--start-maximized") chromedriver_autoinstaller.install() driver = webdriver.Chrome(options=opt) driver.get('https://stackoverflow.com/') here is more info https://pypi.org/project/chromedriver-autoinstaller/


1

To gather the items for your list it looks like you don't need to be specific. Try something like this: List<WebElement> options = driver.findElements(By.xpath(//*[contains(@id,"mat-option-")])); That will populate your options List with all the elements that have an ID that contains mat-option-


0

An alternative solution would be to just delete the Facebook cookie, assuming you're not testing the logout button, but just want to logout or clear your session. driver.delete_all_cookies()


2

As per this article, For QA, Docker solves the classic problem of ensuring that you test the same application you ship. Because everything the application needs to run is packaged in the container, it can run predictably and consistently across the pipeline, and with different configurations -- no more pesky variables to track down. If a configuration issue ...


1

I know you said that you have attempted a Fluent wait but you might not have tried it with these extra methods chained on it. The below wait will check for your element every 500 milliseconds for a maximum of 30 seconds and it will ignore NoSuchElementExceptions. new FluentWait<>(driver) .withTimeout(Duration.ofSeconds(30)) .pollingEvery(...


1

You handle overlay as any other element. If overlay animation is a loading spinner, then you should use an explicit wait in this sequence: Explicit wait for element to be present Explicit wait for element to be not present Reason: If you just wait for element not present, then the code may move to the next line before the overlay has been displayed yet. ...


0

To hide the warning This type of file can harm your computer and enable downloading of xml type of files using Chrome/ChromeDriver you need to: Add the preferences: download.default_directory download.prompt_for_download download.extensions_to_open safebrowsing.enabled As well as add the following arguments to whilelist: --safebrowsing-disable-download-...


0

For me as it turned out it was a chrome driver version issue, after updating the chrome driver the issue was resolved.


2

The short answer is no. The longer answer is I'm not 100% sure but I'm fairly confident the answer is no. I've worked at Sauce Labs for a few years now, several of them in support. I've done a lot of hacking to try to make Safari and other Webdriven browsers play nice, and Safari has always been the most impenetrable. Since creating SafariDriver for Safari ...


0

I agree with the other commenters that the Page Object Model is a great way to structure test code for interacting with the page, however, for the tests themselves, I recommend writing tests for functionality instead of page-by-page. Tests aren't about validating pages, after all. All of your users and most of your staff don't care which page something is ...


1

ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("safebrowsing.enabled", true); prefs.put("profile.default_content_settings.popups", 0); options.setExperimentalOption("prefs", prefs); System.setProperty("webdriver.chrome.driver", "C:\\...


0

Tests are written by engineers. So to break the myth, it's the test architecture, test configuration, test environment, test structure, test code, etc are a few of the factors which in case of incompatibility makes our tests unstable.


1

The id attribute of the <div> tag is dynamic which will change each time the webpage is accessed. In these cases you need to construct dynamic locator strategies as follows: xpath //div[starts-with(@id, 'post-body-')]/div/form/input Note: The second <div> is the first/only child of it's parent, the <form> is the first/only child of it's ...


0

As illustrated in All You Need To Know About UI Testing, Selenium is the best way to go for automated UI testing. A great learning curve helps you run the Selenium tests quickly and easily. To have hassle-free testing, you can use an online cross-browser testing platform that integrates with Selenium and can provide many features through drag and drop ...


0

Please try to this one package com.tests; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.Test; public class IfExampleSelenium { @Testpublic void testPageTitle() { System.out.println("Launching Firefox browser.."); WebDriver driver = new FirefoxDriver(); ...


0

Since Selenium has bindings for C# as well, it is fairly doable to be able to construct your Powershell code depending on those bindings, as @Niels pointed out in the other answer. But if your goal is to run Selenium tests by using Powershell, I would suggest taking a look at the following library: selenium-powershell An example for what you're trying to ...


0

I think something like this might work: $SelectElement = [OpenQA.Selenium.Support.UI.SelectElement]::new($langmenu) $SelectElement.SelectByVisibleText("en") Example from Powershell Selenium select a dropdown menu with FindElementByCssSelector.


0

CSS for the element #nav-link-accountList span.nav-line-1 XPath for the element //a[@id='nav-link-accountList']/div/span[@class='nav-line-1'] You can modify the @FindBy section for CSS @FindBy (how=How.CSS, using= "#nav-link-accountList span.nav-line-1") WebElement loggedInUsernameText; Also you could shorten the element definition @FindBy(...


1

Try to use developer APIs to perform this kind of actions against public sites like Facebook. For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. Aside from being against the usage terms for these sites (where you risk having the account shut down), it is slow and unreliable. The ideal practice is to use the ...


Top 50 recent answers are included