I am trying to test GWT web application using selenium webdriver. I want to fetch the value of selected option of the combobox of gwt. Can please someone tell me how can i do that.
Thanks
You can view value selected, as given below -
Select combo1 = new Select(driver.findElement(By.xpath("xpath of combobox")));
WebElement comboOptionSelected = combo1.getFirstSelectedOption();
System.out.println("Selected option is " + comboOptionSelected.getText());
If you want to fetch the selected option from the combo box follow the below one.
Select dropdown = new Select(driver.findElement(By.id("dropDownElementID")));
WebElement option = dropdown.getFirstSelectedOption();
option.getText();
If you want to select a value use the below one.
dropdown.selectByVisibleText("text");
Try the code and let me know the result.
Related
I'm trying to develop a simple test application (using pytest) that tests an interface with many PyQt5 components (QLabel, QLineEdit, QCheckBox, QRadioButton and QComboBox), but I'm struggling with the combobox one.
How can I click on a QComboBox item using qtbot.mouseClick?
Here's what my QComboBox section looks like.
self.comboBox = QtWidgets.QComboBox(Form)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("ONE")
self.comboBox.addItem("TWO")
self.comboBox.addItem("THREE")
qtbot.keyClicks(self.comboBox, "ONE")
I am trying here the QuickView form of MS Dynamics CRM. The text fields are under IFrame. Through the below java script, it's accessible: fname
//enter fname value
browser.executeScript("window.onload = document.getElementById('NavBarGloablQuickCreate').contentWindow.document.getElementById('firstname_i').value = 'rupam'"); But only first name is selected, if we try to do for the rest fields, it's not working. Hence, decided to do it through protractor code,
// Swtich to iFrame
browser.switchTo().frame(element(by.id("NavBarGloablQuickCreate")));
// Setting anme in first name text field
element(by.id('firstname_i')).sendKeys('Indra');
But here, it says element is not contactable.
You almost had it but were missing the .getWebElement() from your switchTo line. This is required as per the protractor documentation.
// Switch to iFrame
browser.switchTo().frame(element(by.id("NavBarGloablQuickCreate")).getWebElement());
//set name
element(by.id('firstname_i')).sendKeys('Indra');
Can you try the below and let me know.
I am also facing same issue to work with Dynamics CRM Quick view forms.I am trying to set a values on different fields of Quick view forms using SendKeys().But the value is not showing and cursor is not moving from one control to anaother.I have tried to move TAB using protractor TAB values also.But it's not showing.
I have a select tag with some options under it . I select one value out of those along with other field values and move to next page. Once I return to previous page I want to check whether the dropdown value is same as that I selected. How can I get the already selected value using protractor. Can someone please help.
Following #Grasshopper's comment, I read this, and the following worked for me:
expect(element(by.xxxxxx('xxxxxxx')).$('option:checked').getText()).toEqual('xxxxxx')
var dropdownval=element(by.xpath/css("Xpathofdropdown/cssofdropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
The following code helps me to resolve the issue,now the variable contains the value of the dropdown selected
var dropdownval=element(by.xpath("XpathOfDropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
First select the input, then select the option using css, with the option:selected tag:
var selected = element(by.css('#ID_OF_THE_SELECT option:selected'))
I'm trying to test GWT webapp using selenium. I have a testcase where i should remove value from combobox and save the element with null value in it (options in combobox are does not have null value)
My problem occurs when i remove the values. Then GWT opens the combobox to choose value. Normally Escape works on keyboard and firefox closes the combobox, but .sendKeys(Keys.ESCAPE)) does not... and after entity save it uses old value.
I've tried selenium.type, driver.findElement....clear(); , but gwt is still using the previous value.
Any ideas?
Thanks:)
I need to add a dropdown in the New Ticket Screen of OTRS. I managed to add a Dropdown by adding a Dynamic Field with the help of Dynamic Fields Management in Admin Section.
Now my problem is that I want to populate this Dropdown with data that I get from some distant database on the run and dependin on the User Loged In. How can i feed In this Dynamic Data in the DropDown List in OTRS ?
Thank you.
To do such a thing I do not believe is supported from the Dynamic Field UI provided by OTRS.
So you can either:
1- add all the possible values into the drop down box and then hide/show them using code changes in the dtl file. (use javascript).
For creating a new ticket there is either AgentTicketEmail.dtl or AgentTicketPhone.dtl.
There is also the CustomerTicketMessage.dtl if you want to include it in the customer interface too.
2- Add only one value which you can also hide using javascript in the dtl files and just add values to the dropdown list using javascript code.
Example javascript below hides/shows different dynamic fields. You can find what your dynamic field is called by looking at the page source from your browser.
function setdynamicviews(){
switch ($('#Dest').val() ) { //this is where the queue is relevant (Dest = Queue)
case "8\|\|Support": // need to slash escape the pipes
//show dynamic fields
document.getElementById('LabelDynamicField_Product').style.display = 'block';
document.getElementById('LabelDynamicField_SerialNo').style.display = 'block';
break;
default:
//hide dynamic fields.
document.getElementById('LabelDynamicField_Product').style.display = 'none';
document.getElementById('LabelDynamicField_SerialNo').style.display = 'none';
}
}
To add items to usign javascript see here
Yuu have not provided enough information for me to help with getting the information "from some distant database"
Note: if you do change any DTL files or other otrs files you should defrinitely create a theme first see here
Hope this helps.