JavaFX : Trigger event on select already selected combobox value - java

I created one app using JavaFX. When user select any value from Combobox(Dropdown), login popup will display. and on that login window there are two options Login and Cancel.
So the problem is when a user selects any value from the dropdown, login popup will appear. Now user cancels login popup.
If a user wants to open login for the same value selected in dropdown he/she needs to select another value cancel login and select again previous value.
If the user clicks on the dropdown and selects same value event won't trigger.
My code is like following
FXML element
<ComboBox fx:id="userComboBox" onAction="#onUserUpdate" promptText="Select User"/>
Method execute on event trigger
#FXML
public void onUserUpdate() {
//Displaying login popup
}
So I want to trigger the event on select value from the Combobox no matter user is selecting the same value or different value.
Thanks :)

Related

Reuse and concat my Login Scenario to other Scenarios in Cucumber Java with Selenium

I am trying to test Amazon website with 3 scenarios. When first login scenario is done. When trying to other scenarios, it goes to the initial condition and do not logged in when trying to add products in the cart. Basically, I want to login first and concat this functionality to other scenarios or features in Cucumber Selenium.
The below gherkin language is my Amazon.feature;
Feature: Being able to shop through the website in e-commerce platform, Amazon.
Scenario: Login to the system
Given User is on homepage
When Click accept cookies
When User click login button
When User click EmailBlank
And Enter e-mail address
And User press continue button
When User click PasswordBlank
And Enter password
And Click SignIn button
Scenario: Find the product from the website
When Click the search button
When Write product name
When Click search button
When Filter for Shipped by Amazon
When Filter for Apple
Scenario: Adding and deleting product to cart
When Click the first product
When Add to Cart
And Close the Cart
And Click the Cart
When Check at cart page
When Delete the product
Most probably I should use background keyword, but can't solve it.
In case all these scenarios you have in one feature file, then it is ok if you logged into the system in the first scenario and just execute other scenarios without relogging.
But you logged out from the app in the first Scenario: And Click SignIn button. Therefore the next scenario fails.
2 options here (or 1st, or 2nd):
do not log out in the first scenario (remove And Click SignIn button.)
make a Background for login like
Background:
#Given User is on homepage
But in this second case with the background you must log out in the end of each your scenario.
Hope it helps.
UPD based on the comment:
Feature: Being able to shop through the website in e-commerce platform, Amazon.
Background
Given User is on homepage (I am assuming this step is for login)
When Click accept cookies
When User click login button
When User click EmailBlank
And Enter e-mail address
And User press continue button
When User click PasswordBlank
And Enter password
And Click SignIn button
Scenario: Find the product from the websitep
When Click the search button
When Write product name
When Click search button
When Filter for Shipped by Amazon
When Filter for Apple
**Then LOG OUT**
Scenario: Adding and deleting product to cart
When Click the first product
When Add to Cart
And Close the Cart
And Click the Cart
When Check at cart page
When Delete the product
**Then LOG OUT**

Is that possible to select another radio button, when the other one is already selected and setted in disabled mode?

In the below code, depending upon the selection(single/multiple selection), iam using the resources images to display accordingly. I have selected the radio button and made it as readonly. Now if i select any other radio button, is that possible to disable the previous selection without removing its readonly mode? only the first radio button field is in readonly mode. all the other fields are editable.
case READ_ONLY:
selectionModel.setSelected(widget, !selectionModel.isSelected(widget));
if (isSingleSelection) {
$(checkboxCell).toggleClass(resources.styles().unselected(),
resources.styles().readOnlySelected());
} else {
$(checkboxCell).toggleClass(resources.styles().unChecked(),
resources.styles().readOnlyChecked());
}

i want to navigate to dialog box that contains cancel and delete.I want to select delete option and come back to previous page

*********delete button from dropdown list
snW.SelectDropown_byXpath("STOCKTHRES_DEL_XPATH")
snW.getDriver().switchTo().activeelement();
clicking delete from populated dialog box
snW.clickById("STOCKTHRES_DELK")

How to override next button event of JFace wizard

I have a wizard comprising of three pages page1 , page2, page3.
I'm in page 2 and I press "Next" button , where some validations for duplicate creation needs to verified based on inputs form page1 and a selection inputs entered in page2.
Which method should i override inorder to include my validations and pop up a message box(complaining about duplicacy) on click of Next button of page2.
You can override WizardPage.getNextPage() and return null to prevent the next button from operating.
It is more usual to validate the user input as it happens and call WizardPage.setPageComplete(false) to disable the next button completely until the page is valid.
Call WizardPage.setErrorMessage(msg) or WizardPage.setMessage(msg, type) to display messages.

Handling dynamically changing element id - using selenium webdriver

I m having the login page, when click login button it opens the new tab.
i moved the control to new window using,
driver.switchTo().window("_blank");
When I click one Button it will open the new popup (that popup is not a normal window it is a iframe).
I have selected a popup window using,
driver.switchTo().frame("frameName");
That popup has the list of records; each record has the separate "select" option (with the dynamically changing id's).
driver.findElement(By.xpath("//a[#id='radgrdPeople_ctl00_ctl04_lnkSelect']")).click();
When selecting the record from list, the popup window will be closed and the page will get refreshed.
Now I want to return the control to my parent window for doing some other stuff.
The record got selected successfully. But i could not able to focus the parent window again.
I have tried:
driver.switchTo().defaultcontent();
driver.switchTo().window("_blank");
And
driver.getWindowHandles()
Still I m getting the same problem.
I don't know whether I have to use any java script executor for handling the dynamically changing element id's.
Could u any one please help me on this....
Thanks in Advance.
By
K.Ranjithkumar
In the post after clicking the login button you used WindowName to switch over to the new window. But, in the tried solution, you used empty string to switch over to the new window.
You should make first window as parent window
String parent=driver.getwindowhandle;
// then, set String popup to be equal to window handle of the
// popup window
driver.switchTo().window( popup);
driver.findElement(By.id("okbutton")).click(); //assumes close of popup
Now after performing tasks on popup window, return control to parent window:
driver.switchTo().window( parent );// switch back to parent window
driver.switchTo().defaultcontent(); // reset iframe context

Categories