How to select value from search drop down - selenium

How to select value from this type of drop down.
// select value from dropdown
Select dropdown = new Select(driver.findElement(By.id("select2-operative_id-container")));
dropdown.selectByVisibleText("Administrator");
and
Try above both method but not able to select value.
Please consider below image for better Understanding.
click this Image Link
For drop down value I am not able to select Xpath.

This is select drop down.
Select dropdown = new Select(driver.findElement(By.xpath("put here xpath")));
dropdown.selectByValue("A");
For bootstrap dropdown
# you have to first click on the arrow icon(v) of the drop down.
driver.findElement(By.xpath("put here xpath of the v icon")).click();
# Then find the xpath of the value which you have to select from drop down and then apply click operation on it.
driver.findElement(By.xpath("put here xpath of the value within drop down")).click();

Inspect the dropdown find the value and select your chosen option.
Select dropdown = new Select(driver.findElement(By.id("select2-operative_id-container")));
dropdown.selectByValue("Administrator");
or another method than should work is to send keys to select the option.
WebElement dropdown = new WebElement(driver.findElement(By.id("select2-operative_id-container")));
dropdown.sendKeys("Administrator");

You can use SelectByValue method.
Add the value name as string as below.
Select oSelect = new Select(driver.findElement(By.id("select2-operative_id-container")));
oSelect.selectByValue(<your value>);

Related

How do deselect a particular SELECT option in a non multi-select selenium

Select sel41 = new Select(TestUtility.getElementByXpath("//[#id=\'supervisor_select_list_id\']"));
//sel41.deselectByValue("167805");
sel41.selectByVisibleText("Employer Demo2 [HR Director]");
I want to deselect the default selected and select another value

Like Clause over an 'Element' - ORACLE APEX

I encounter some problems that i don't understand with APEX.... Well, let's be specific.
I ve got a select element retrieving a top 50 of most liked url (P11_URL). This is populate by a table view, TOp_Domains.
I create an element called "Context" that have to print all text containing the URL selected by the user from the element select. Those Texts come from another table, let's say "twitter_post".
I create a dynamic action (show only) with this sql/statement:
Select TXT, NB_RT, RANK
from myschema.twitter_post
where TXT like '%:P11_URL%'
group by TXT, NB_RT, RANK
.... and it doesn't work... I think APEX don't like like clause... But i don't know how to do. Let's keep in min an url could have been shared by multiple Tweets, that's why this element "context" is important for me.
I tried to bypass the problem by building a State (in french Statique) and a dynamic action that will refresh the state but it doesn't work neither... bouhououououou
TriX
Right click on the 'P11_URL' and create DA. Event :change, Item:P11_URL. As the true action of the DA, select 'Set Value'. Write your query in the sql stmt area. In the page items to submit, select 'P11_URL' . In the 'Affected Items': select 'Context'.
Query should be :
Select TXT, NB_RT, RANK
from myschema.twitter_post
where TXT like '%' || :P11_URL || '%'
group by TXT, NB_RT, RANK
So
Thanks to #Madona... Their example made me realised my mistake. I wrote the answer here for futher help if somebody encouter the same porblem.
A list select element get as arguments a display value (the one you want to be shown in your screen.... if you want so....^^ ) and a return value (in order, I think to linked dynamic actions). So to solved my problem i had to shape my sql statement as:
select hashtags d, hastags r
from my table
order by 1
[let s say that now in Apex it s an object called P1_HASHTAGS]
First step problem solving.
In fact, the ranking as second value, as i put into my sql statement was making some mitsakens into my 'Where like' clause search... well... Newbie am i!
Second step was to correctly formate the sql statement receiving the datas from my select lov (P1_HASHTAGS) into my interactive report. As shown here:
Select Id, hashtags
from my table
where txt like '%'||:P1_HASHTAGS||'%'
And it works!
Thank you Madona your example helped me figure my mistakes!

How can I stop executing code after getting a result?

I have a textbox named "Search" and code that filters a customer out by name. I also want to display the whole table if the textbox is empty but don't know how to do it.
NOTE : I am using Microsoft Access.
Here is my code :
SELECT * FROM Customers
WHERE Forms.[Form1].[Text4] = Forms.[Form1].[Text4] AND FirstName=Forms.[Form1].[Text4];
Thank you for any help.
You need validate if text is empty or filter to another rules, this can be something like this:
SELECT * FROM Customers WHERE Forms.[Form1].[Text4] IS NULL OR FirstName = Forms.[Form1].[Text4];

Pentaho report designer , checkbox parameter checked by default

we have set a check box parameter in Pentaho report designer .
When we launch the report the check box is unchecked .
what we want is , to set the default value of that Check box to be checked
so when we launch the report we don't have to check it .
Question: And how would you do the same things on Pentaho cde?
Answer:
Step1: First create one simple datasource.
=> Datasource name: query
=> Query:
SELECT "option1"
UNION
SELECT "option2"
UNION
SELECT "option3"
UNION
SELECT "option4"
UNION
SELECT "option5"
Step2:- Goto component panel and then select "Check Component". click on advanced properties.
Name: checkcomponent,
Parameter: checked,
Datasource: query,
HtmlObject: panel_1 (assumption),
preexecution: function f(){checked = ['option1','option2'];}
that's it run dashboard and see. Defaultly option1 and option2 are selected.
Thank you.

how to write xpath with a variable

I have a xpath= //*[#id='00QE000000gQ9fv_ACTION_COLUMN']/a[2]/span
in this xpath 00QE000000gQ9fv is dynamic and _ACTION_COLUMN remains same.
I stored 00QE000000gQ9fv in a String variable as recordId i.e
String recordId = 00QE000000gQ9fv
Now i want a xpath which contains recordId variable.
your xpath will be - //*[contains(#id,'_ACTION_COLUMN')]/a[2]/span
Make sure _ACTION_COLUMN is unique or is the first element in your html so that u grab hold of the right element.
Edit 1 according to your comment.
Try this: //*[contains(#id,'"+recordId +"')]/a[2]/span
or
//*[#id='"+ recordId +"_ACTION_COLUMN']/a[2]/span