How do I specify an id for a fieldset in crispy-forms - fieldset

I have a django crispy form. Everything is in order, however, I would like to specify an id for it instead of having it autogenerate for me. Is there a way to accomplish this?
I have read the documentation and scoured the internet for sometime, but have not had any luck.
Any help would be appreciated.

I found it. There is a kwarg id that can be applied to the invocation of the crispy form.

I ran into this same question. Here is how I solved it per redcloud1800's initial post:
Fieldset(
'Registration Goal',
'registration_goal',
id = 'registration_goal_field'
),
The id kwarg in Fieldset adds that id to the HTML tag like: <fieldset id='registration_goal_field'>

Related

Selenium C# - I'm unable to find an element on this page using any of the locators

This was just a random script I made to complete a quiz but I can't seem to access the final element. I want to select the element, click the element and then send some text to the element.
I have tried to access the input box by class name, CssSelector and by XPath.
The website is https://www.16personalities.com/free-personality-test
Here are the XPaths I have tried:
//*[contains(#class, 'email-wrapper')]
//div[contains(#placeholder, 'your#email.com')]
//div[#class="row request-info-wrapper"]
//*[#id='request - email']"
Any help is greatly appreciated as I'm new to the framework and would very much like to know what I'm not understanding about locators! Thank you!
EDIT:
I can't seem to target this element or any of its children:
You have selected wrong tag DIV.Try this following Xpath. All should work.
"//input[#id='request-email']"
Or
"//input[#name='email']"
Or
"//input[#placeholder='your#email.com']"
Your field has a (presently) unique ID of "request-email".
Thus you can simply use, as a CSS selector,
('#request-email')
Then, in you can simply tell Selenium to hit ENTER to save your data. Let me know if you need help doing that.

Make Text Field item as Read Only in APEX 5.0

I have some text field page items on my APEX 5.0 page and I want to make the textboxes as read only/non-editable. During the page load I want to use these text boxes for only the data display on the page and should be non-editable.
Can somebody advice on how to do that? What attributes need to set for this?
This answer is a bit late to the party, but I found myself confronted to this problem and I wanted to share the solution I came up with.
In fact you just need to create your item as a text area, let say P1_Text_Area and you give it a readonly attribute using JavaScript. Write thoses 2 lines in the "Function and Global Variable Declaration" of your page:
var disItem = document.getElementById('P1_Text_Area');
disItem.readOnly = true;
Hope this helps someone in need.
in item properties find the
Read Only group
and set Read Only Condition Type as Always
or the option that suits to you
You can use disabled + save session state ==> read only

Dynamic xpath handling

Below is my xpath
driver.findElement(By.xpath("html/body/div[9]/div/a/div")).click();
In above code value of div[6] is keep changing.
Sometimes it will
driver.findElement(By.xpath("html/body/div[6]/div/a/div")).click();
or
driver.findElement(By.xpath("html/body/div[1]/div/a/div")).click();
Please provide solution.
We faced this issue with dynamic page content making XPath identification basically useless. We took the decision to make sure everything that needed to be identified in a test would have an id set. So:
driver.findElement(By.xpath("html/body/div[6]/div/a/div")).click();
becomes:
driver.findElement(By.id("myDivId")).click();
Use div 'id' or 'class' instead of div[6].
like:
/html/body/div[#id='div_id']/div/a/div
(or)
/html/body/div[#class='div_className']/div/a/div

Selenium select element with multiple attributes

How do I select a div using both it's id and class in Selenium firefox addon?
EDIT: I managed to solve it, I used an xpath expression with both the attributes #id= and #class =
I stumbled upon this question and thought I would leave an example of the answer that the OP didn't leave (as requested by vincebowdren above):
//*/fieldset[#class="openable"][#id="activityFieldset"]
This would select a fieldset element with the openeable class and activityFieldset id.
I would like to post another correct answer for future reference.
First of all there have been other correct answers here:
https://stackoverflow.com/a/42996525/6569715
A valid example would be to define a locator by multiple attributes:
HEADER_1_TEXT = (
By.XPATH,
"//h2[#class='text-primary' and #id='my-id' and text() ='Get started with Us']")
I managed to solve it, I used an xpath expression with both the attributes #id= and #class =

How to find all WebElements on page by presence of id?

I know I can find element by id:
driver.findElement(By.xpath("//*[#id='some_id']"));
And I can find all elements with this id, but I want to find all elements with an id attribute. I'm looking for something like:
driver.findElements(By.xpath("//*[#id]"));
// or
driver.findElements(By.xpath("//*[#id='*']"));
// or
driver.findElements(By.xpath("//*[contains(#id)]"));
I'm using Java. Thanks!
UPD: The only solution for me is to get all elements by "//*", go through them and get their id attributes. Is there a way to get all attributes at once, something like "//*#A" from Java?
Attribute A of element where A contains 't'
//E[contains(#A,'t')]/#A
or
//E[contains(#A,'t')]#A
Attribute A of any element
//*/#A
or //*#A
so I use java too. So if you need to find all elements with id attribute you can simply use
driver.findElements(By.xpath(//*#id))
Hope this helps you.
ALso look here. Nice manual for xpath and css selectors
have you tried "//*[contains(#id, '')]"