MOBILE-4270 behat: Select option values by text
This commit is contained in:
		
							parent
							
								
									a8e7e61e1e
								
							
						
					
					
						commit
						0e6eaeee46
					
				@ -422,13 +422,22 @@ export class TestingBehatRuntimeService {
 | 
			
		||||
    async setField(field: string, value: string): Promise<string> {
 | 
			
		||||
        this.log('Action - Set field ' + field + ' to: ' + value);
 | 
			
		||||
 | 
			
		||||
        const found = TestingBehatDomUtils.findField(field);
 | 
			
		||||
        const input = TestingBehatDomUtils.findField(field);
 | 
			
		||||
 | 
			
		||||
        if (!found) {
 | 
			
		||||
        if (!input) {
 | 
			
		||||
            return 'ERROR: No element matches field to set.';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await TestingBehatDomUtils.setElementValue(found, value);
 | 
			
		||||
        if (input instanceof HTMLSelectElement) {
 | 
			
		||||
            const options = Array.from(input.querySelectorAll('option'));
 | 
			
		||||
 | 
			
		||||
            value = options.find(option => option.value === value)?.value
 | 
			
		||||
                ?? options.find(option => option.text === value)?.value
 | 
			
		||||
                ?? options.find(option => option.text.includes(value))?.value
 | 
			
		||||
                ?? value;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        await TestingBehatDomUtils.setElementValue(input, value);
 | 
			
		||||
 | 
			
		||||
        return 'OK';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user